Package

org.apache.spark.sql

types

Permalink

package types

Contains a type system for attributes produced by relations, including complex types like structs, arrays and maps.

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. types
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class ArrayType(elementType: DataType, containsNull: Boolean) extends DataType with Product with Serializable

    Permalink

    The data type for collections of multiple values.

    The data type for collections of multiple values. Internally these are represented as columns that contain a scala.collection.Seq.

    Please use DataTypes.createArrayType() to create a specific instance.

    An ArrayType object comprises two fields, elementType: DataType and containsNull: Boolean. The field of elementType is used to specify the type of array elements. The field of containsNull is used to specify if the array has null values.

    elementType

    The data type of values.

    containsNull

    Indicates if values have null values

    Annotations
    @Stable()
    Since

    1.3.0

  2. abstract class AtomicType extends DataType

    Permalink

    An internal type used to represent everything that is not null, UDTs, arrays, structs, and maps.

    An internal type used to represent everything that is not null, UDTs, arrays, structs, and maps.

    Attributes
    protected[org.apache.spark.sql]
  3. class BinaryType extends AtomicType

    Permalink

    The data type representing Array[Byte] values.

    The data type representing Array[Byte] values. Please use the singleton DataTypes.BinaryType.

    Annotations
    @Stable()
  4. class BooleanType extends AtomicType

    Permalink

    The data type representing Boolean values.

    The data type representing Boolean values. Please use the singleton DataTypes.BooleanType.

    Annotations
    @Stable()
    Since

    1.3.0

  5. class ByteType extends IntegralType

    Permalink

    The data type representing Byte values.

    The data type representing Byte values. Please use the singleton DataTypes.ByteType.

    Annotations
    @Stable()
    Since

    1.3.0

  6. class CalendarIntervalType extends DataType

    Permalink

    The data type representing calendar time intervals.

    The data type representing calendar time intervals. The calendar time interval is stored internally in two components: number of months the number of microseconds.

    Please use the singleton DataTypes.CalendarIntervalType.

    Annotations
    @Stable()
    Since

    1.5.0

    Note

    Calendar intervals are not comparable.

  7. abstract class DataType extends AbstractDataType

    Permalink

    The base type of all Spark SQL data types.

    The base type of all Spark SQL data types.

    Annotations
    @Stable()
    Since

    1.3.0

  8. class DataTypes extends AnyRef

    Permalink
  9. class DateType extends AtomicType

    Permalink

    A date type, supporting "0001-01-01" through "9999-12-31".

    A date type, supporting "0001-01-01" through "9999-12-31".

    Please use the singleton DataTypes.DateType.

    Internally, this is represented as the number of days from 1970-01-01.

    Annotations
    @Stable()
    Since

    1.3.0

  10. final class Decimal extends Ordered[Decimal] with Serializable

    Permalink

    A mutable implementation of BigDecimal that can hold a Long if values are small enough.

    A mutable implementation of BigDecimal that can hold a Long if values are small enough.

    The semantics of the fields are as follows: - _precision and _scale represent the SQL precision and scale we are looking for - If decimalVal is set, it represents the whole decimal value - Otherwise, the decimal value is longVal / (10 ** _scale)

    Annotations
    @Unstable()
  11. case class DecimalType(precision: Int, scale: Int) extends FractionalType with Product with Serializable

    Permalink

    The data type representing java.math.BigDecimal values.

    The data type representing java.math.BigDecimal values. A Decimal that must have fixed precision (the maximum number of digits) and scale (the number of digits on right side of dot).

    The precision can be up to 38, scale can also be up to 38 (less or equal to precision).

    The default precision and scale is (10, 0).

    Please use DataTypes.createDecimalType() to create a specific instance.

    Annotations
    @Stable()
    Since

    1.3.0

  12. class DoubleType extends FractionalType

    Permalink

    The data type representing Double values.

    The data type representing Double values. Please use the singleton DataTypes.DoubleType.

    Annotations
    @Stable()
    Since

    1.3.0

  13. class FloatType extends FractionalType

    Permalink

    The data type representing Float values.

    The data type representing Float values. Please use the singleton DataTypes.FloatType.

    Annotations
    @Stable()
    Since

    1.3.0

  14. class IntegerType extends IntegralType

    Permalink

    The data type representing Int values.

    The data type representing Int values. Please use the singleton DataTypes.IntegerType.

    Annotations
    @Stable()
    Since

    1.3.0

  15. class LongType extends IntegralType

    Permalink

    The data type representing Long values.

    The data type representing Long values. Please use the singleton DataTypes.LongType.

    Annotations
    @Stable()
    Since

    1.3.0

  16. case class MapType(keyType: DataType, valueType: DataType, valueContainsNull: Boolean) extends DataType with Product with Serializable

    Permalink

    The data type for Maps.

    The data type for Maps. Keys in a map are not allowed to have null values.

    Please use DataTypes.createMapType() to create a specific instance.

    keyType

    The data type of map keys.

    valueType

    The data type of map values.

    valueContainsNull

    Indicates if map values have null values.

    Annotations
    @Stable()
  17. sealed class Metadata extends Serializable

    Permalink

    Metadata is a wrapper over Map[String, Any] that limits the value type to simple ones: Boolean, Long, Double, String, Metadata, Array[Boolean], Array[Long], Array[Double], Array[String], and Array[Metadata].

    Metadata is a wrapper over Map[String, Any] that limits the value type to simple ones: Boolean, Long, Double, String, Metadata, Array[Boolean], Array[Long], Array[Double], Array[String], and Array[Metadata]. JSON is used for serialization.

    The default constructor is private. User should use either MetadataBuilder or Metadata.fromJson() to create Metadata instances.

    Annotations
    @Stable()
    Since

    1.3.0

  18. class MetadataBuilder extends AnyRef

    Permalink

    Builder for Metadata.

    Builder for Metadata. If there is a key collision, the latter will overwrite the former.

    Annotations
    @Stable()
    Since

    1.3.0

  19. class NullType extends DataType

    Permalink

    The data type representing NULL values.

    The data type representing NULL values. Please use the singleton DataTypes.NullType.

    Annotations
    @Stable()
    Since

    1.3.0

  20. abstract class NumericType extends AtomicType

    Permalink

    Numeric data types.

    Numeric data types.

    Annotations
    @Stable()
    Since

    1.3.0

  21. case class ObjectType(cls: Class[_]) extends DataType with Product with Serializable

    Permalink

    Represents a JVM object that is passing through Spark SQL expression evaluation.

    Represents a JVM object that is passing through Spark SQL expression evaluation.

    Annotations
    @Evolving()
  22. class SQLUserDefinedType extends Annotation with Annotation with ClassfileAnnotation

    Permalink
  23. class ShortType extends IntegralType

    Permalink

    The data type representing Short values.

    The data type representing Short values. Please use the singleton DataTypes.ShortType.

    Annotations
    @Stable()
    Since

    1.3.0

  24. class StringType extends AtomicType

    Permalink

    The data type representing String values.

    The data type representing String values. Please use the singleton DataTypes.StringType.

    Annotations
    @Stable()
    Since

    1.3.0

  25. case class StructField(name: String, dataType: DataType, nullable: Boolean = true, metadata: Metadata = Metadata.empty) extends Product with Serializable

    Permalink

    A field inside a StructType.

    A field inside a StructType.

    name

    The name of this field.

    dataType

    The data type of this field.

    nullable

    Indicates if values of this field can be null values.

    metadata

    The metadata of this field. The metadata should be preserved during transformation if the content of the column is not modified, e.g, in selection.

    Annotations
    @Stable()
    Since

    1.3.0

  26. case class StructType(fields: Array[StructField]) extends DataType with Seq[StructField] with Product with Serializable

    Permalink

    A StructType object can be constructed by

    A StructType object can be constructed by

    StructType(fields: Seq[StructField])

    For a StructType object, one or multiple StructFields can be extracted by names. If multiple StructFields are extracted, a StructType object will be returned. If a provided name does not have a matching field, it will be ignored. For the case of extracting a single StructField, a null will be returned. Example:

    import org.apache.spark.sql._
    import org.apache.spark.sql.types._
    
    val struct =
      StructType(
        StructField("a", IntegerType, true) ::
        StructField("b", LongType, false) ::
        StructField("c", BooleanType, false) :: Nil)
    
    // Extract a single StructField.
    val singleField = struct("b")
    // singleField: StructField = StructField(b,LongType,false)
    
    // This struct does not have a field called "d". null will be returned.
    val nonExisting = struct("d")
    // nonExisting: StructField = null
    
    // Extract multiple StructFields. Field names are provided in a set.
    // A StructType object will be returned.
    val twoFields = struct(Set("b", "c"))
    // twoFields: StructType =
    //   StructType(List(StructField(b,LongType,false), StructField(c,BooleanType,false)))
    
    // Any names without matching fields will be ignored.
    // For the case shown below, "d" will be ignored and
    // it is treated as struct(Set("b", "c")).
    val ignoreNonExisting = struct(Set("b", "c", "d"))
    // ignoreNonExisting: StructType =
    //   StructType(List(StructField(b,LongType,false), StructField(c,BooleanType,false)))

    A org.apache.spark.sql.Row object is used as a value of the StructType. Example:

    import org.apache.spark.sql._
    
    val innerStruct =
      StructType(
        StructField("f1", IntegerType, true) ::
        StructField("f2", LongType, false) ::
        StructField("f3", BooleanType, false) :: Nil)
    
    val struct = StructType(
      StructField("a", innerStruct, true) :: Nil)
    
    // Create a Row with the schema defined by struct
    val row = Row(Row(1, 2, true))
    // row: Row = [[1,2,true]]
    Annotations
    @Stable()
    Since

    1.3.0

  27. class TimestampType extends AtomicType

    Permalink

    The data type representing java.sql.Timestamp values.

    The data type representing java.sql.Timestamp values. Please use the singleton DataTypes.TimestampType.

    Annotations
    @Stable()
    Since

    1.3.0

Value Members

  1. object AnyDataType extends AbstractDataType

    Permalink

    An AbstractDataType that matches any concrete data types.

    An AbstractDataType that matches any concrete data types.

    Attributes
    protected[org.apache.spark.sql]
  2. object ArrayType extends AbstractDataType with Serializable

    Permalink

    Companion object for ArrayType.

    Companion object for ArrayType.

    Annotations
    @Stable()
    Since

    1.3.0

  3. object BinaryType extends BinaryType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  4. object BooleanType extends BooleanType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  5. object ByteType extends ByteType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  6. object CalendarIntervalType extends CalendarIntervalType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.5.0

  7. object DataType

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  8. object DateType extends DateType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  9. object Decimal extends Serializable

    Permalink
    Annotations
    @Unstable()
  10. object DecimalType extends AbstractDataType with Serializable

    Permalink

    Extra factory methods and pattern matchers for Decimals.

    Extra factory methods and pattern matchers for Decimals.

    Annotations
    @Stable()
    Since

    1.3.0

  11. object DoubleType extends DoubleType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  12. object FloatType extends FloatType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  13. object IntegerType extends IntegerType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  14. object LongType extends LongType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  15. object MapType extends AbstractDataType with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  16. object Metadata extends Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  17. object NullType extends NullType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  18. object ObjectType extends AbstractDataType with Serializable

    Permalink
    Annotations
    @Evolving()
  19. object ShortType extends ShortType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  20. object StringType extends StringType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  21. object StructType extends AbstractDataType with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

  22. object TimestampType extends TimestampType with Product with Serializable

    Permalink

    Annotations
    @Stable()
    Since

    1.3.0

Inherited from AnyRef

Inherited from Any

Ungrouped