Skip to main content

build_table_meta_from_column_metadatas

Function build_table_meta_from_column_metadatas 

Source
pub(crate) fn build_table_meta_from_column_metadatas(
    table_id: TableId,
    table_ref: TableReference<'_>,
    table_meta: &TableMeta,
    name_to_ids: Option<HashMap<String, u32>>,
    column_metadata: &[ColumnMetadata],
) -> Result<TableMeta>
Expand description

Builds a TableMeta from the provided [ColumnMetadata]s, preserving schema column order from table_meta and taking the primary key order from the input tags.

The input [ColumnMetadata]s determine which columns currently exist in region metadata:

  • Columns present in table_meta but missing from column_metadata are dropped.
  • Columns present in both retain the column order from table_meta.schema.
  • Columns present only in column_metadata are appended.
  • Primary key order follows the tag columns in column_metadata, which the physical-table reconcile paths feed in the regions’ key order (table_meta.primary_key_indices only determines which columns must remain tags). The logical-table reconcile path feeds columns in column-position order and relies on a subsequent sort_columns() call.

Returns an error if:

  • Any column is missing in the name_to_ids(if name_to_ids is provided).
  • The column id in table metadata is not the same as the column id in the column metadata.(if name_to_ids is provided)
  • The table index is missing in the column metadata.
  • Any primary key column of table_meta is not [SemanticType::Tag] in column_metadata.
  • The primary key or partition key columns are missing in the column metadata.