You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "CTTY (via GitHub)" <gi...@apache.org> on 2025/07/30 00:00:11 UTC

[PR] fix: Fallback to field.name to get field position when PARQUET:field_id is unavailable [iceberg-rust]

CTTY opened a new pull request, #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   - Closes #1560 
   
   ## What changes are included in this PR?
   
   <!--
   Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates.
   -->
   - Fallback to use field.name to get field position
   - Minor typo fixes
   
   ## Are these changes tested?
   Yes, added uts
   <!--
   Specify what test covers (unit test, integration test, etc.).
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(arrow): Allow ArrowArrayAccessor to use field.name to match fields [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561#discussion_r2276129838


##########
crates/iceberg/src/writer/file_writer/parquet_writer.rs:
##########
@@ -70,10 +71,30 @@ impl<T: LocationGenerator, F: FileNameGenerator> ParquetWriterBuilder<T, F> {
         file_io: FileIO,
         location_generator: T,
         file_name_generator: F,
+    ) -> Self {
+        Self::new_with_match_mode(
+            props,
+            schema,
+            FieldMatchMode::Id,
+            file_io,
+            location_generator,
+            file_name_generator,
+        )
+    }
+
+    /// Create a new `ParquetWriterBuilder` with custom match mode
+    pub fn new_with_match_mode(

Review Comment:
   ```suggestion
       pub fn with_field_match_mode(
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: Fallback to field.name to get field position when PARQUET:field_id is unavailable [iceberg-rust]

Posted by "fvaleye (via GitHub)" <gi...@apache.org>.
fvaleye commented on code in PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561#discussion_r2246062312


##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -459,14 +459,17 @@ impl PartnerAccessor<ArrayRef> for ArrowArrayAccessor {
             .fields()
             .iter()
             .position(|arrow_field| {
+                // match by ID if available, otherwise try matching by name
                 get_field_id(arrow_field)
-                    .map(|id| id == field.id)
-                    .unwrap_or(false)
+                    .map_or(arrow_field.name() == &field.name, |id| id == field.id)
             })
             .ok_or_else(|| {
                 Error::new(
                     ErrorKind::DataInvalid,
-                    format!("Field id {} not found in struct array", field.id),
+                    format!(
+                        "Field with id={} or name={} not found in struct array",
+                        field.id, field.name
+                    ),

Review Comment:
   **nitpick:** It might be helpful to log the available field names, since neither `field.id` nor `field.name` matched.
   
   ```suggestion
                       format!(
                           "Field with id={} or name={} not found in struct array. Available fields: [{}]",
                           field.id,
                           field.name,
                           struct_array
                               .fields()
                               .iter()
                               .map(|f| f.name().as_str())
                               .collect::<Vec<_>>()
                               .join(", ")
                       ),
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: Fallback to field.name to get field position when PARQUET:field_id is unavailable [iceberg-rust]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561#issuecomment-3160162779

   @CTTY Thanks for raising this PR, as suggested in #1560 I think we need to rely on name-mapping here.
   
   Iceberg is designed to do operations lazy, meaning that we typically don't rewrite data unless it is neccessary. For example, if you rename a field, it will still find the field with the original name using the field-IDs. This is the case when you have a new table that has the field-IDs correctly set.
   
   However, in the age of big-data, and to make it easier for users to migrate to Iceberg, we also support importing existing Parquet files where the field-IDs are missing. In this case, we'll [use `name-mapping` to map names to a field-ID](https://iceberg.apache.org/spec/#column-projection). In the case of a rename, the old and the new name will map to the same ID, so we can still look up the field after a rename.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: Fallback to field.name to get field position when PARQUET:field_id is unavailable [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561#issuecomment-3143972062

   Let's discuss in this issue: https://github.com/apache/iceberg-rust/issues/1560#issuecomment-3143970409


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: Fallback to field.name to get field position when PARQUET:field_id is unavailable [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561#discussion_r2256730104


##########
crates/iceberg/src/arrow/value.rs:
##########
@@ -451,22 +483,31 @@ impl PartnerAccessor<ArrayRef> for ArrowArrayAccessor {
             .ok_or_else(|| {
                 Error::new(
                     ErrorKind::DataInvalid,
-                    "The struct partner is not a struct array",
+                    format!(
+                        "The struct partner is not a struct array, partner: {:?}",
+                        struct_partner
+                    ),
                 )
             })?;
 
         let field_pos = struct_array
             .fields()
             .iter()
-            .position(|arrow_field| {
-                get_field_id(arrow_field)
-                    .map(|id| id == field.id)
-                    .unwrap_or(false)
-            })
+            .position(|arrow_field| self.arrow_field_matches_id(arrow_field, field.id))

Review Comment:
   I think we still have misunderstanding here. As I have said https://github.com/apache/iceberg-rust/issues/1560#issuecomment-3149922656 , for the `nan_val_cnt` case, we should match field to arrow array using the field's position(e.g. the rank of this field in struct) rather than by id or name.  It's not easy to accomplish with currentl interface, so we should change the interface of `PartnerAccessor`, see comments below.



##########
crates/iceberg/src/spec/schema/visitor.rs:
##########
@@ -190,7 +190,7 @@ pub trait SchemaWithPartnerVisitor<P> {
 /// Accessor used to get child partner from parent partner.
 pub trait PartnerAccessor<P> {
     /// Get the struct partner from schema partner.
-    fn struct_parner<'a>(&self, schema_partner: &'a P) -> Result<&'a P>;
+    fn struct_partner<'a>(&self, schema_partner: &'a P) -> Result<&'a P>;
     /// Get the field partner from struct partner.
     fn field_partner<'a>(&self, struct_partner: &'a P, field: &NestedField) -> Result<&'a P>;

Review Comment:
   ```suggestion
       fn field_partner<'a>(&self, struct_partner: &'a P, field: &NestedField, field_pos: usize) -> Result<&'a P>;
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] feat(arrow): Allow ArrowArrayAccessor to use field.name to match fields [iceberg-rust]

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 merged PR #1561:
URL: https://github.com/apache/iceberg-rust/pull/1561


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org