hsiang-c commented on code in PR #2865:
URL: https://github.com/apache/iceberg-rust/pull/2865#discussion_r3632401549


##########
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:
   (nit) Shall we follow Iceberg Java's logic: 
https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/MetadataColumns.java#L145-L151



-- 
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]

Reply via email to