Skip to content

Instantly share code, notes, and snippets.

@ldacosta
Created March 31, 2015 18:08
Show Gist options
  • Save ldacosta/801afe65d783bc2d7f3c to your computer and use it in GitHub Desktop.
Save ldacosta/801afe65d783bc2d7f3c to your computer and use it in GitHub Desktop.
StructField from case class
import org.apache.spark.sql._
case class CC1(i: Int, s: Option[Int])
case class MockExpected2(i: Int, s: String, d: Option[Double], cc1: Option[CC1])
object MockExpected2 {
val expectedSchema2: StructType = {
StructType(Seq(
StructField(name = "cc1", dataType = StructType({
Seq(
StructField(name = "i", dataType = IntegerType, nullable = false),
StructField(name = "s", dataType = StringType, nullable = true))
}), nullable = false),
StructField(name = "i", dataType = IntegerType, nullable = false),
StructField(name = "s", dataType = StringType, nullable = false),
StructField(name = "d", dataType = DoubleType, nullable = true)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment