May 17, 2021 Spark Programming guide
The type of number
Datetime type
DateType: Represents the value of the year, month, and day that contains the field
Complex type
containsNull
to indicate whether
ArrayType
has a null value
valueContainsNull
to indicate whether
MapType
has a null value
StructType (fields): Represents a value that has a
StructFields (fields)
structure
StructType
the name of the
name
dataType
type of the field, and
nullable
value of the field has a null value.
All of Spark's data types are defined in package
org.apache.spark.sql
which you can access
import org.apache.spark.sql._
The data type | The type of value in Scala | Access or create an API for the data type |
---|---|---|
ByteType | Byte | ByteType |
ShortType | Short | ShortType |
IntegerType | Int | IntegerType |
LongType | Long | LongType |
FloatType | Float | FloatType |
DoubleType | Double | DoubleType |
DecimalType | scala.math.BigDecimal | DecimalType |
StringType | String | StringType |
BinaryType | Array[Byte] | BinaryType |
BooleanType | Boolean | BooleanType |
TimestampType | java.sql.Timestamp | TimestampType |
DateType | java.sql.Date | DateType |
ArrayType | scala.collection.Seq | ArrayType (elementType, "containsNull") Note that containsNull defaults to true |
MapType | scala.collection.Map | MapType (keyType, valueType, valueContainsNull) Note that valueContainsNull defaults to true |
StructType | org.apache.spark.sql.Row | StructType (fields), note that Fields is a StructField sequence, and two StructFields with the same name are not allowed |
StructField | The value type in Scala of the data type of this field (For example, Int for a StructField with the data type IntegerType) | StructField(name, dataType, nullable) |