Class StructField

Object
io.delta.kernel.types.StructField

@Evolving public class StructField extends Object
Represents a subfield of StructType with additional properties and metadata.
Since:
3.0.0
  • Field Details

    • METADATA_SPEC_KEY

      public static final String METADATA_SPEC_KEY
      The existence of this key indicates that a column is a metadata column and its values indicates what kind of MetadataColumnSpec it is.
      See Also:
    • IS_INTERNAL_COLUMN_KEY

      public static final String 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

      public static StructField 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

      public static final String COLLATIONS_METADATA_KEY
      See Also:
    • FROM_TYPE_KEY

      public static final String FROM_TYPE_KEY
      See Also:
    • TO_TYPE_KEY

      public static final String TO_TYPE_KEY
      See Also:
    • FIELD_PATH_KEY

      public static final String FIELD_PATH_KEY
      See Also:
    • DELTA_TYPE_CHANGES_KEY

      public static final String DELTA_TYPE_CHANGES_KEY
      See Also:
  • Constructor Details

  • Method Details

    • createMetadataColumn

      public static StructField createMetadataColumn(String name, MetadataColumnSpec colSpec)
      Creates a metadata column of the given colSpec with the given name.
      Parameters:
      name - Name of the metadata column
      colSpec - Type of the metadata column
      Returns:
      A StructField representing the metadata column
    • getName

      public String getName()
      Returns:
      the name of this field
    • getDataType

      public DataType getDataType()
      Returns:
      the data type of this field
    • getMetadata

      public FieldMetadata getMetadata()
      Returns:
      the metadata for this field
    • isNullable

      public boolean isNullable()
      Returns:
      whether this field allows to have a null value.
    • getTypeChanges

      public List<TypeChange> 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

      public MetadataColumnSpec getMetadataColumnSpec()
      Returns the type of metadata column if this is a metadata column, otherwise returns null.
    • isInternalColumn

      public boolean isInternalColumn()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • isWriteCompatible

      public boolean isWriteCompatible(StructField other)
      Checks whether the given other is compatible with this StructField when writing data. Collation differences are ignored.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • withNewMetadata

      public StructField withNewMetadata(FieldMetadata metadata)
    • withTypeChanges

      public StructField withTypeChanges(List<TypeChange> typeChanges)
      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

      public StructField withDataType(DataType newType)
      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.