Package org.apache.spark.sql.types
Class DataTypes
Object
org.apache.spark.sql.types.DataTypes
To get/create specific data type, users should use singleton objects and factory methods
provided by this class.
- Since:
- 1.3.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DataType
Gets the BinaryType object.static final DataType
Gets the BooleanType object.static final DataType
Gets the ByteType object.static final DataType
Gets the CalendarIntervalType object.static final DataType
Gets the DateType object.static final DataType
Gets the DoubleType object.static final DataType
Gets the FloatType object.static final DataType
Gets the IntegerType object.static final DataType
Gets the LongType object.static final DataType
Gets the NullType object.static final DataType
Gets the ShortType object.static final DataType
Gets the StringType object.static final DataType
Gets the TimestampNTZType object.static final DataType
Gets the TimestampType object. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ArrayType
createArrayType
(DataType elementType) Creates an ArrayType by specifying the data type of elements (elementType
).static ArrayType
createArrayType
(DataType elementType, boolean containsNull) Creates an ArrayType by specifying the data type of elements (elementType
) and whether the array contains null values (containsNull
).static DayTimeIntervalType
Creates a DayTimeIntervalType with default start and end fields: interval day to second.static DayTimeIntervalType
createDayTimeIntervalType
(byte startField, byte endField) Creates a DayTimeIntervalType by specifying the start and end fields.static DecimalType
Creates a DecimalType with default precision and scale, which are 10 and 0.static DecimalType
createDecimalType
(int precision, int scale) Creates a DecimalType by specifying the precision and scale.static MapType
createMapType
(DataType keyType, DataType valueType) Creates a MapType by specifying the data type of keys (keyType
) and values (keyType
).static MapType
createMapType
(DataType keyType, DataType valueType, boolean valueContainsNull) Creates a MapType by specifying the data type of keys (keyType
), the data type of values (keyType
), and whether values contain any null value (valueContainsNull
).static StructField
createStructField
(String name, DataType dataType, boolean nullable) Creates a StructField with empty metadata.static StructField
createStructField
(String name, DataType dataType, boolean nullable, Metadata metadata) Creates a StructField by specifying the name (name
), data type (dataType
) and whether values of this field can be null values (nullable
).static StructType
createStructType
(List<StructField> fields) Creates a StructType with the given list of StructFields (fields
).static StructType
createStructType
(StructField[] fields) Creates a StructType with the given StructField array (fields
).static YearMonthIntervalType
Creates a YearMonthIntervalType with default start and end fields: interval year to month.static YearMonthIntervalType
createYearMonthIntervalType
(byte startField, byte endField) Creates a YearMonthIntervalType by specifying the start and end fields.
-
Field Details
-
StringType
Gets the StringType object. -
BinaryType
Gets the BinaryType object. -
BooleanType
Gets the BooleanType object. -
DateType
Gets the DateType object. -
TimestampType
Gets the TimestampType object. -
TimestampNTZType
Gets the TimestampNTZType object. -
CalendarIntervalType
Gets the CalendarIntervalType object. -
DoubleType
Gets the DoubleType object. -
FloatType
Gets the FloatType object. -
ByteType
Gets the ByteType object. -
IntegerType
Gets the IntegerType object. -
LongType
Gets the LongType object. -
ShortType
Gets the ShortType object. -
NullType
Gets the NullType object.
-
-
Constructor Details
-
DataTypes
public DataTypes()
-
-
Method Details
-
createArrayType
Creates an ArrayType by specifying the data type of elements (elementType
). The field ofcontainsNull
is set totrue
. -
createArrayType
Creates an ArrayType by specifying the data type of elements (elementType
) and whether the array contains null values (containsNull
). -
createDecimalType
Creates a DecimalType by specifying the precision and scale. -
createDecimalType
Creates a DecimalType with default precision and scale, which are 10 and 0. -
createDayTimeIntervalType
Creates a DayTimeIntervalType by specifying the start and end fields. -
createDayTimeIntervalType
Creates a DayTimeIntervalType with default start and end fields: interval day to second. -
createYearMonthIntervalType
Creates a YearMonthIntervalType by specifying the start and end fields. -
createYearMonthIntervalType
Creates a YearMonthIntervalType with default start and end fields: interval year to month. -
createMapType
Creates a MapType by specifying the data type of keys (keyType
) and values (keyType
). The field ofvalueContainsNull
is set totrue
. -
createMapType
public static MapType createMapType(DataType keyType, DataType valueType, boolean valueContainsNull) Creates a MapType by specifying the data type of keys (keyType
), the data type of values (keyType
), and whether values contain any null value (valueContainsNull
). -
createStructField
public static StructField createStructField(String name, DataType dataType, boolean nullable, Metadata metadata) Creates a StructField by specifying the name (name
), data type (dataType
) and whether values of this field can be null values (nullable
). -
createStructField
Creates a StructField with empty metadata. -
createStructType
Creates a StructType with the given list of StructFields (fields
). -
createStructType
Creates a StructType with the given StructField array (fields
).
-