Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.apache.spark.sql.types._ // You'll need this to evaluate its output
- object StructFmt {
- def asScala(field: StructField): String = field.dataType match {
- case struct: StructType => s"""StructField("${field.name}",""" + asScala(struct) + s", ${field.nullable})"
- case _ => s"""StructField("${field.name}", ${field.dataType}, ${field.nullable})"""
- }
- def asScala(struct: StructType): String = "StructType(Seq(" + (for(field <- struct) yield asScala(field)).mkString(",") + "))"
- }
Add Comment
Please, Sign In to add comment