gengliangwang opened a new issue, #3838:
URL: https://github.com/apache/iceberg-rust/issues/3838

   ### Apache Iceberg Rust version
   
   main (`ea17ba2`)
   
   ### Describe the bug
   
   `SnapshotSummaryCollector::add_file` and `remove_file` 
(`crates/iceberg/src/spec/snapshot_summary.rs`) update the per-partition 
metrics only when the file's partition tuple is not empty:
   
   ```rust
   self.metrics.add_file(data_file);
   if !data_file.partition.fields().is_empty() {
       self.update_partition_metrics(schema, partition_spec, data_file, true);
   }
   ```
   
   A file of an unpartitioned spec is therefore not counted as a changed 
partition:
   
   - a snapshot that only changes such files has no `changed-partition-count` 
in its summary;
   - a snapshot that changes files of an unpartitioned spec and files of a 
partitioned spec (a table whose spec was changed) reports a count that is one 
too low.
   
   Iceberg's Java library counts these files under the empty partition path: 
`SnapshotSummary.Builder.updatePartitions` calls 
`spec.partitionToPath(file.partition())` for every file, which is `""` for an 
unpartitioned spec. An append to an unpartitioned table committed by Java has 
`"changed-partition-count": "1"`; the same append committed by iceberg-rust has 
no such entry.
   
   ### To Reproduce
   
   ```rust
   let mut collector = SnapshotSummaryCollector::default();
   // `data_file.partition` is `Struct::empty()`
   collector.add_file(&data_file, schema, 
Arc::new(PartitionSpec::unpartition_spec()));
   let summary = collector.build();
   assert_eq!(summary.get("changed-partition-count").map(String::as_str), 
Some("1")); // fails: the key is missing
   ```
   
   The same shows in the summary of a snapshot made by a fast append to an 
unpartitioned table.
   
   ### Expected behavior
   
   `changed-partition-count` is `1` for a snapshot that changes files of an 
unpartitioned table, as in snapshots committed by Iceberg's Java library.
   
   ### Willingness to contribute
   
   I can contribute a fix for this bug independently
   


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