
42
|
第
3
章
$SPARK_HOME/bin/spark-shell
scala>
import org.apache.spark.sql.types._
import org.apache.spark.sql.types._
scala>
val nameTypes = StringType
nameTypes:
org.apache.spark.sql.types.StringType.type = StringType
scala>
val firstName = nameTypes
firstName:
org.apache.spark.sql.types.StringType.type = StringType
scala>
val lastName = nameTypes
lastName:
org.apache.spark.sql.types.StringType.type = StringType
表
3-2
列出了
Spark
基本数据类型与
Scala
数据类型的对应关系。除了
DecimalType
,其他
数据类型都是
DataTypes
类的子类。
表3-2:Spark基本数据类型与Scala数据类型
数据类型 Scala中对应的数据类型 用于实例化的API
ByteType Byte DataTypes.ByteType
ShortType Short DataTypes.ShortType
IntegerType Int DataTypes.IntegerType
LongType ...