All Implemented Interfaces:
Serializable
Direct Known Subclasses:
VectorUDT

public abstract class UserDefinedType<UserType> extends DataType implements Serializable

The data type for User Defined Types (UDTs).

This interface allows a user to make their own classes more interoperable with SparkSQL; e.g., by creating a UserDefinedType for a class X, it becomes possible to create a DataFrame which has class X in the schema.

For SparkSQL to recognize UDTs, the UDT must be annotated with SQLUserDefinedType.

The conversion via serialize occurs when instantiating a DataFrame from another RDD. The conversion via deserialize occurs when reading from a DataFrame.

See Also:
  • Constructor Details

    • UserDefinedType

      public UserDefinedType()

  • Method Details

    • sqlType

      public abstract DataType sqlType()

      Underlying storage type for this UDT

    • pyUDT

      Paired Python UDT class, if exists.

    • serializedPyClass

      public String serializedPyClass()

      Serialized Python UDT class, if exists.

    • serialize

      Convert the user type to a SQL datum

      Parameters:
      obj - (undocumented)
      Returns:
      (undocumented)
    • deserialize

      Convert a SQL datum to the user type

    • userClass

      Class object for the UserType

      Returns:
      (undocumented)
    • defaultSize

      public int defaultSize()

      Description copied from class: DataType

      The default size of a value of this data type, used internally for size estimation.

      Specified by:
      defaultSize in class DataType
      Returns:
      (undocumented)
    • sql

      Overrides:
      sql in class DataType
    • hashCode

      public int hashCode()

      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)

      Overrides:
      equals in class Object
    • catalogString

      public String catalogString()

      Description copied from class: DataType

      String representation for the type saved in external catalogs.

      Overrides:
      catalogString in class DataType
    • stringifyValue

      This method is used to convert the value of a UDT to a string representation.

      By default, it simply calls toString on the object.

      Parameters:
      obj - The object to convert to a string.
      Returns:
      A string representation of the object.
      Since:
      4.1.0