xanderbailey commented on code in PR #3057:
URL: https://github.com/apache/iceberg-rust/pull/3057#discussion_r4515478146


##########
crates/iceberg/src/spec/table_metadata_builder.rs:
##########
@@ -1235,6 +1316,32 @@ impl TableMetadataBuilder {
             .collect()
     }
 
+    /// Gives each field of `spec` the highest id an equivalent field has in 
the table's specs, or
+    /// the next id above `last_partition_id`.
+    fn reassign_partition_field_ids(&self, spec: PartitionSpec) -> 
Result<UnboundPartitionSpec> {
+        let mut field_ids = Self::highest_equivalent_field_ids(
+            self.metadata
+                .partition_specs
+                .values()
+                .flat_map(|spec| spec.fields()),
+        );
+        let mut last_partition_id = self.metadata.last_partition_id;
+
+        let fields = spec.fields().iter().map(|field| {
+            let field_id = *field_ids
+                .entry((vec![field.source_id], field.transform))
+                .or_insert_with(|| {
+                    last_partition_id += 1;

Review Comment:
   Tried this, but `add_partition_spec` records `AddSpec` from the unbound 
spec, so new fields would reach a REST catalog without ids, and a Java server 
would number them from 1000, colliding with reused ids. Java's 
`buildReplacement` sends the bound ids, so I've kept the assignment here. 
Making `add_partition_spec` record the ids it assigns would change it for every 
caller, so I'd rather do that separately.



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