Class MaterializedRowTrackingColumn
Object
io.delta.kernel.internal.rowtracking.MaterializedRowTrackingColumn
A collection of helper methods for working with materialized row tracking columns.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MaterializedRowTrackingColumnStatic instance for the materialized row commit version column.static final MaterializedRowTrackingColumnStatic instance for the materialized row ID column. -
Method Summary
Modifier and TypeMethodDescriptionAssigns materialized column names for ROW_ID and ROW_COMMIT_VERSION if row tracking is enabled and the column names have not been assigned yet.static List<StructField> convertToPhysicalColumn(StructField logicalField, StructType logicalSchema, Metadata metadata) Converts a logical row tracking field to its physical counterpart(s).Returns the prefix to use for generating the materialized column name.Returns the configuration property name associated with this materialized column.getPhysicalColumnName(Map<String, String> configuration) Gets the physical column name from the table configuration.static voidthrowIfColumnNamesConflictWithSchema(Metadata metadata) Validates that the materialized column names for ROW_ID and ROW_COMMIT_VERSION do not conflict with any existing logical or physical column names in the table's schema.static ColumnarBatchtransformPhysicalData(ColumnarBatch dataBatch, Row scanFile, StructType logicalSchema, Map<String, String> configuration, Engine engine) Computes row IDs and row commit versions based on their materialized values if present in the data returned by the Parquet reader, using the base row ID and default row commit version from the AddFile otherwise.static voidvalidateRowTrackingConfigsNotMissing(Metadata metadata, String tablePath) Validates that materialized column names for ROW_ID and ROW_COMMIT_VERSION are not missing when row tracking is enabled.
-
Field Details
-
MATERIALIZED_ROW_ID
Static instance for the materialized row ID column. -
MATERIALIZED_ROW_COMMIT_VERSION
Static instance for the materialized row commit version column.
-
-
Method Details
-
getMaterializedColumnNameProperty
Returns the configuration property name associated with this materialized column. -
getMaterializedColumnNamePrefix
Returns the prefix to use for generating the materialized column name. -
throwIfColumnNamesConflictWithSchema
Validates that the materialized column names for ROW_ID and ROW_COMMIT_VERSION do not conflict with any existing logical or physical column names in the table's schema.- Parameters:
metadata- The currentMetadataof the table.
-
validateRowTrackingConfigsNotMissing
Validates that materialized column names for ROW_ID and ROW_COMMIT_VERSION are not missing when row tracking is enabled. This should be called for existing tables to ensure that row tracking configs are present when they should be.- Parameters:
metadata- The currentMetadataof the table.
-
assignMaterializedColumnNamesIfNeeded
Assigns materialized column names for ROW_ID and ROW_COMMIT_VERSION if row tracking is enabled and the column names have not been assigned yet.- Parameters:
metadata- The current Metadata of the table.- Returns:
- An Optional containing updated metadata if any assignments occurred; Optional.empty() otherwise.
-
convertToPhysicalColumn
public static List<StructField> convertToPhysicalColumn(StructField logicalField, StructType logicalSchema, Metadata metadata) Converts a logical row tracking field to its physical counterpart(s).Since computing the row ID requires the row index, requesting a row tracking column can require adding two columns to the physical schema.
Note that we must not mark the physical columns as metadata columns because as far as the parquet reader is concerned, these columns are not metadata columns.
- Parameters:
logicalField- The logical field to convert.logicalSchema- The logical schema containing the field.metadata- The current metadata of the table.- Returns:
- A list of
StructFields representing the physical columns corresponding to the logical field.
-
transformPhysicalData
public static ColumnarBatch transformPhysicalData(ColumnarBatch dataBatch, Row scanFile, StructType logicalSchema, Map<String, String> configuration, Engine engine) Computes row IDs and row commit versions based on their materialized values if present in the data returned by the Parquet reader, using the base row ID and default row commit version from the AddFile otherwise.- Parameters:
dataBatch- a batch of physical data read from the table.scanFile- theRowrepresenting the scan file metadata.logicalSchema- the logical schema of the query.configuration- the configuration map containing table metadata.engine- theEngineto use for expression evaluation.- Returns:
- a new
ColumnarBatchwith logical row tracking columns
-
getPhysicalColumnName
Gets the physical column name from the table configuration.- Parameters:
configuration- the table configuration map- Returns:
- the physical column name
- Throws:
IllegalArgumentException- if the materialized column name is missing from the configuration
-