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
FieldsModifier and TypeFieldDescriptionstatic final DataTypeGets the BinaryType object.static final DataTypeGets the BooleanType object.static final DataTypeGets the ByteType object.static final DataTypeGets the CalendarIntervalType object.static final DataTypeGets the DateType object.static final DataTypeGets the DoubleType object.static final DataTypeGets the FloatType object.static final DataTypeGets the IntegerType object.static final DataTypeGets the LongType object.static final DataTypeGets the NullType object.static final DataTypeGets the ShortType object.static final DataTypeGets the StringType object.static final DataTypeGets the TimestampNTZType object.static final DataTypeGets the TimestampType object.static final DataTypeGets the VariantType object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ArrayTypecreateArrayType(DataType elementType) Creates an ArrayType by specifying the data type of elements (elementType).static ArrayTypecreateArrayType(DataType elementType, boolean containsNull) Creates an ArrayType by specifying the data type of elements (elementType) and whether the array contains null values (containsNull).static CharTypecreateCharType(int length) Creates a CharType with the given length.static DayTimeIntervalTypeCreates a DayTimeIntervalType with default start and end fields: interval day to second.static DayTimeIntervalTypecreateDayTimeIntervalType(byte startField, byte endField) Creates a DayTimeIntervalType by specifying the start and end fields.static DecimalTypeCreates a DecimalType with default precision and scale, which are 10 and 0.static DecimalTypecreateDecimalType(int precision, int scale) Creates a DecimalType by specifying the precision and scale.static MapTypecreateMapType(DataType keyType, DataType valueType) Creates a MapType by specifying the data type of keys (keyType) and values (keyType).static MapTypecreateMapType(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 StructFieldcreateStructField(String name, DataType dataType, boolean nullable) Creates a StructField with empty metadata.static StructFieldcreateStructField(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 StructTypecreateStructType(List<StructField> fields) Creates a StructType with the given list of StructFields (fields).static StructTypecreateStructType(StructField[] fields) Creates a StructType with the given StructField array (fields).static VarcharTypecreateVarcharType(int length) Creates a VarcharType with the given length.static YearMonthIntervalTypeCreates a YearMonthIntervalType with default start and end fields: interval year to month.static YearMonthIntervalTypecreateYearMonthIntervalType(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. -
VariantType
Gets the VariantType object.
-
-
Constructor Details
-
DataTypes
public DataTypes()
-
-
Method Details
-
createArrayType
Creates an ArrayType by specifying the data type of elements (elementType). The field ofcontainsNullis 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 ofvalueContainsNullis 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). -
createCharType
Creates a CharType with the given length.- Since:
- 4.0.0
-
createVarcharType
Creates a VarcharType with the given length.- Since:
- 4.0.0
-