July 2017
Intermediate to advanced
796 pages
18h 55m
English
A schema is described using StructType, which is a collection of StructField objects.
Using these imports, we can define a custom explicit schema.
First, import the necessary classes:
scala> import org.apache.spark.sql.types.{StructType, IntegerType, StringType}import org.apache.spark.sql.types.{StructType, IntegerType, StringType}
Define a schema with two columns/fields-an Integer followed by a String:
scala> val schema = new StructType().add("i", IntegerType).add("s", StringType)schema: org.apache.spark.sql.types.StructType = StructType(StructField(i,IntegerType,true), ...Read now
Unlock full access