LuciferYang commented on code in PR #2865:
URL: https://github.com/apache/iceberg-rust/pull/2865#discussion_r3636838302
##########
crates/iceberg/src/metadata_columns.rs:
##########
@@ -478,15 +484,26 @@ pub fn is_metadata_field(field_id: i32) -> bool {
)
}
-/// Checks if a column name is a metadata column.
+/// Checks if a column name is a metadata column of a data table.
+///
+/// Only the `_`-prefixed reserved names (`_file`, `_pos`, `_partition`,
`_spec_id`,
+/// `_deleted`, and the changelog/row-lineage columns) are metadata columns
that can be
+/// projected in a data-table scan. Per the Iceberg spec, reserved metadata
column names
+/// are `_`-prefixed precisely so they cannot collide with user data columns.
+///
+/// The bare names `pos` and `file_path` are the internal columns of a
position-delete
+/// file, not projectable metadata columns of a data table, so they are
excluded here even
+/// though [`get_metadata_field_id`] still maps them to their reserved field
ids. Without
+/// this exclusion a real data column named `pos` or `file_path` would be
shadowed and fail
+/// to scan.
///
/// # Arguments
/// * `column_name` - The column name to check
///
/// # Returns
-/// `true` if the column name is a metadata column, `false` otherwise
+/// `true` if the column name is a projectable data-table metadata column,
`false` otherwise
pub fn is_metadata_column_name(column_name: &str) -> bool {
- get_metadata_field_id(column_name).is_ok()
+ column_name.starts_with('_') && get_metadata_field_id(column_name).is_ok()
Review Comment:
Done in 5f7f8dce. `is_metadata_column_name` is now an explicit allowlist of
the seven names Java's `isMetadataColumn(String)` accepts: the six
`META_COLUMNS` keys plus the `_partition` special case. I also tightened
`is_metadata_field` to the seven ids in `META_IDS`, so the id side mirrors Java
too. `get_metadata_field_id` and `get_metadata_field` are unchanged, so they
still map the bare names and resolve the reserved ids for the delete read path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]