UserDefinedType (Spark 4.2.0 JavaDoc)
- 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 Summary
Constructors
-
Method Summary
String representation for the type saved in external catalogs.
intThe default size of a value of this data type, used internally for size estimation.
Convert a SQL datum to the user type
booleaninthashCode()pyUDT()Paired Python UDT class, if exists.
Convert the user type to a SQL datum
Serialized Python UDT class, if exists.
sql()sqlType()Underlying storage type for this UDT
This method is used to convert the value of a UDT to a string representation.
Class object for the UserType
Methods inherited from class org.apache.spark.sql.types.DataType
COLLATIONS_METADATA_KEY, equalsIgnoreCaseAndNullability, equalsIgnoreNullability, equalsStructurally, equalsStructurallyByName, fromDDL, fromJson, json, parseTypeWithFallback, prettyJson, simpleString, typeName
-
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:
DataTypeThe default size of a value of this data type, used internally for size estimation.
- Specified by:
defaultSizein classDataType- Returns:
- (undocumented)
-
sql
-
hashCode
public int hashCode()
-
equals
public boolean equals
(Object other) -
catalogString
public String catalogString()
Description copied from class:
DataTypeString representation for the type saved in external catalogs.
- Overrides:
catalogStringin classDataType
-
stringifyValue
This method is used to convert the value of a UDT to a string representation.
By default, it simply calls
toStringon the object.- Parameters:
obj- The object to convert to a string.- Returns:
- A string representation of the object.
- Since:
- 4.1.0
-