Monday, July 15, 2019

StructType and StructFields

StructType — Data Type for Schema Definition

StructType is a built-in data type that is a collection of StructFields.
StructType is used to define a schema or its part.
You can compare two StructType instances to see whether they are equal.
import org.apache.spark.sql.types.StructType

val schemaUntyped = new StructType()
  .add("a", "int")
  .add("b", "string")

import org.apache.spark.sql.types.{IntegerType, StringType}
val schemaTyped = new StructType()
  .add("a", IntegerType)
  .add("b", StringType)

scala> schemaUntyped == schemaTyped
res0: Boolean = true

No comments:

Post a Comment