Package io.delta.kernel.types
Class StructField
Object
io.delta.kernel.types.StructField
Represents a subfield of
StructType with additional properties and metadata.- Since:
- 3.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic StructFieldThe default row index metadata column used by Kernel.static final Stringstatic final Stringstatic final Stringstatic final StringIndicates that a column was requested for internal computations and should not be returned to the user.static final StringThe existence of this key indicates that a column is a metadata column and its values indicates what kind ofMetadataColumnSpecit is.static final String -
Constructor Summary
ConstructorsConstructorDescriptionStructField(String name, DataType dataType, boolean nullable) StructField(String name, DataType dataType, boolean nullable, FieldMetadata metadata) -
Method Summary
Modifier and TypeMethodDescriptionstatic StructFieldcreateMetadataColumn(String name, MetadataColumnSpec colSpec) Creates a metadata column of the givencolSpecwith the givenname.booleanReturns the type of metadata column if this is a metadata column, otherwise returns null.getName()Returns the list of type changes for this field.inthashCode()booleanbooleanbooleanbooleanbooleanisWriteCompatible(StructField other) Checks whether the givenotheris compatible with thisStructFieldwhen writing data.toString()withDataType(DataType newType) Creates a copy of this StructField with the specified data type.withNewMetadata(FieldMetadata metadata) withTypeChanges(List<TypeChange> typeChanges) Creates a copy of this StructField with the specified type changes.
-
Field Details
-
METADATA_SPEC_KEY
The existence of this key indicates that a column is a metadata column and its values indicates what kind ofMetadataColumnSpecit is.- See Also:
-
IS_INTERNAL_COLUMN_KEY
Indicates that a column was requested for internal computations and should not be returned to the user.- See Also:
-
DEFAULT_ROW_INDEX_COLUMN
The default row index metadata column used by Kernel. When present, this column must be populated with row index of each row when reading from Parquet. -
COLLATIONS_METADATA_KEY
- See Also:
-
FROM_TYPE_KEY
- See Also:
-
TO_TYPE_KEY
- See Also:
-
FIELD_PATH_KEY
- See Also:
-
DELTA_TYPE_CHANGES_KEY
- See Also:
-
-
Constructor Details
-
StructField
-
StructField
-
-
Method Details
-
createMetadataColumn
Creates a metadata column of the givencolSpecwith the givenname.- Parameters:
name- Name of the metadata columncolSpec- Type of the metadata column- Returns:
- A StructField representing the metadata column
-
getName
- Returns:
- the name of this field
-
getDataType
- Returns:
- the data type of this field
-
getMetadata
- Returns:
- the metadata for this field
-
isNullable
public boolean isNullable()- Returns:
- whether this field allows to have a
nullvalue.
-
getTypeChanges
Returns the list of type changes for this field. A field can go through multiple type changes (e.g.int->long->decimal). Changes are ordered from least recent to most recent in the list (index 0 is the oldest change).N.B. Type changes should be entirely managed by the Delta Kernel, users are not expected to maintain this field.
-
isMetadataColumn
public boolean isMetadataColumn() -
isDataColumn
public boolean isDataColumn() -
getMetadataColumnSpec
Returns the type of metadata column if this is a metadata column, otherwise returns null. -
isInternalColumn
public boolean isInternalColumn() -
toString
-
equals
-
isWriteCompatible
Checks whether the givenotheris compatible with thisStructFieldwhen writing data. Collation differences are ignored. -
hashCode
public int hashCode() -
withNewMetadata
-
withTypeChanges
Creates a copy of this StructField with the specified type changes.N.B. Type changes should be entirely managed by the Delta Kernel, users are not expected to maintain this field.
- Parameters:
typeChanges- The list of type changes to set- Returns:
- A new StructField with the same properties but with the specified type changes
-
withDataType
Creates a copy of this StructField with the specified data type.TypeChanges are NOT updated as part of this call.
- Parameters:
newType- The new type to use in the StructField.- Returns:
- A new StructField with the same properties but with the specified data type.
-