org.apache.spark.sql.types
Class DataTypes

Object
  extended by org.apache.spark.sql.types.DataTypes

public class DataTypes
extends Object

To get/create specific data type, users should use singleton objects and factory methods provided by this class.


Field Summary
static DataType BinaryType
          Gets the BinaryType object.
static DataType BooleanType
          Gets the BooleanType object.
static DataType ByteType
          Gets the ByteType object.
static DataType DateType
          Gets the DateType object.
static DataType DoubleType
          Gets the DoubleType object.
static DataType FloatType
          Gets the FloatType object.
static DataType IntegerType
          Gets the IntegerType object.
static DataType LongType
          Gets the LongType object.
static DataType NullType
          Gets the NullType object.
static DataType ShortType
          Gets the ShortType object.
static DataType StringType
          Gets the StringType object.
static DataType TimestampType
          Gets the TimestampType object.
 
Constructor Summary
DataTypes()
           
 
Method Summary
static 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 DecimalType createDecimalType()
           
static DecimalType createDecimalType(int precision, int 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(java.util.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).
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

StringType

public static final DataType StringType
Gets the StringType object.


BinaryType

public static final DataType BinaryType
Gets the BinaryType object.


BooleanType

public static final DataType BooleanType
Gets the BooleanType object.


DateType

public static final DataType DateType
Gets the DateType object.


TimestampType

public static final DataType TimestampType
Gets the TimestampType object.


DoubleType

public static final DataType DoubleType
Gets the DoubleType object.


FloatType

public static final DataType FloatType
Gets the FloatType object.


ByteType

public static final DataType ByteType
Gets the ByteType object.


IntegerType

public static final DataType IntegerType
Gets the IntegerType object.


LongType

public static final DataType LongType
Gets the LongType object.


ShortType

public static final DataType ShortType
Gets the ShortType object.


NullType

public static final DataType NullType
Gets the NullType object.

Constructor Detail

DataTypes

public DataTypes()
Method Detail

createArrayType

public static ArrayType createArrayType(DataType elementType)
Creates an ArrayType by specifying the data type of elements (elementType). The field of containsNull is set to true.


createArrayType

public 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).


createDecimalType

public static DecimalType createDecimalType(int precision,
                                            int scale)

createDecimalType

public static DecimalType createDecimalType()

createMapType

public static MapType createMapType(DataType keyType,
                                    DataType valueType)
Creates a MapType by specifying the data type of keys (keyType) and values (keyType). The field of valueContainsNull is set to true.


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

public static StructField createStructField(String name,
                                            DataType dataType,
                                            boolean nullable)
Creates a StructField with empty metadata.

See Also:
createStructField(String, DataType, boolean, Metadata)

createStructType

public static StructType createStructType(java.util.List<StructField> fields)
Creates a StructType with the given list of StructFields (fields).


createStructType

public static StructType createStructType(StructField[] fields)
Creates a StructType with the given StructField array (fields).