xanderbailey commented on code in PR #3701:
URL: https://github.com/apache/iceberg-rust/pull/3701#discussion_r4606832537
##########
crates/iceberg/src/transaction/mod.rs:
##########
@@ -125,11 +125,36 @@ impl Transaction {
let updated_table = Self::update_table_metadata(table, &updates)?;
existing_updates.extend(updates);
- existing_requirements.extend(requirements);
+ Self::merge_requirements(existing_requirements, requirements);
Ok(updated_table)
}
+ // Catalogs check against the base, so keep only the first requirement per
value.
+ fn merge_requirements(
+ existing_requirements: &mut Vec<TableRequirement>,
+ requirements: Vec<TableRequirement>,
+ ) {
+ for requirement in requirements {
+ if !existing_requirements
+ .iter()
+ .any(|existing| Self::asserts_same_value(existing,
&requirement))
+ {
+ existing_requirements.push(requirement);
+ }
+ }
+ }
+
+ fn asserts_same_value(left: &TableRequirement, right: &TableRequirement)
-> bool {
+ match (left, right) {
+ (
+ TableRequirement::RefSnapshotIdMatch { r#ref: left, .. },
+ TableRequirement::RefSnapshotIdMatch { r#ref: right, .. },
+ ) => left == right,
+ _ => std::mem::discriminant(left) == std::mem::discriminant(right),
+ }
+ }
Review Comment:
The replace action will assert main at the base snapshot, so a concurrent
commit to main conflicts and the transaction retries against the refreshed
table. With that, keeping the first requirement holds for replace-then-append,
I'll happily add that test in the next PR if that works? Is it better for my to
put that PR up now to see where we're going?
--
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]