Repository navigation
Parse unrecognized transform names as Transform::Unknown - #2790
moomindani wants to merge 3 commits into
Conversation
|
Gentle ping — this has been open for ~3 weeks with CI green and no review yet. It's a small, self-contained change: Scoped deliberately to the non-breaking subset — preserving the original name for round-trip needs a @blackmwk you've reviewed most of the recent |
af9372b to
0823b86
Compare
0823b86 to
56aca78
Compare
|
Rebased onto current Verified locally with the pinned toolchain: @CTTY @kevinjqliu this is a small spec-conformance fix — v3 readers are required to read tables with unknown transforms rather than fail parsing, matching Java's |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
56aca78 to
47398ef
Compare
|
Not stale. Rebased onto current @laskoviymishka you reviewed and merged the recent |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
Per the V3 spec, readers are required to read tables with unknown transforms, ignoring them. FromStr for Transform returned an error for any unrecognized name, so table metadata using a transform iceberg-rust does not know failed to load. Match Java's Transforms.fromString: only exactly well-formed known transforms parse as known; everything else parses as Transform::Unknown. Well-formed parameters that overflow u32 still error.
47398ef to
ca2fbce
Compare
laskoviymishka
left a comment
There was a problem hiding this comment.
Thanks for keeping this rebased and green since July. Loading tables with foreign transforms is the right goal, but as it stands a load followed by any metadata commit rewrites zorder or bucketv2[4] to "unknown", which main can't do today because it refuses the load. That one thread is what I'd hold this on, and either fix there works for me; the case-sensitivity comment is a nit. Could you also note in the description that projecting _partition and Transform::project still error for such tables?
| } else { | ||
| // Per the spec, v3 readers are required to read tables with | ||
| // unknown transforms, ignoring them | ||
| Transform::Unknown |
There was a problem hiding this comment.
Should we stop the write path from persisting a fallback Unknown before this lands? With this branch, metadata using zorder or bucketv2[4] in a spec or sort order loads, and a TableMetadataBuilder::new_from_metadata(..).set_properties(..).build() commit then writes "unknown", since Serialize goes through Display. On main that metadata fails to load, and Java's UnknownTransform keeps the name.
Carrying the name (Unknown(String), the #2789 change) or rejecting serialization of a parsed-fallback Unknown would both close it; which do you prefer? A test that loads such a spec and pins what gets written back would hold either fix.
There was a problem hiding this comment.
Went with rejecting the write, and kept Unknown(String) for #2789 since it would drop Copy from Transform. The check is in TableMetadata::write_to rather than in Serialize for Transform: FileScanTask serializes its partition_spec and sort_order, so failing there would break shipping scan tasks for these tables. Every non-REST catalog writes metadata through write_to; a REST commit sends only TableUpdates, so the server keeps the original name. test_write_rejects_unknown_partition_transform and test_write_rejects_unknown_sort_transform load zorder / bucketv2[4], apply set_properties, and pin that the write fails and no file is written.
| #[test] | ||
| fn test_parse_unrecognized_transform_as_unknown() { | ||
| // Per the spec, v3 readers are required to read tables with unknown | ||
| // transforms, ignoring them. This matches Java's Transforms.fromString, |
There was a problem hiding this comment.
Should the name match be case-insensitive, or this comment (and the description) say it matches Java for lowercase names only? Java compares every name with equalsIgnoreCase, so Bucket[4] or Identity parse as known there and become Unknown here.
There was a problem hiding this comment.
Made it case-insensitive to match equalsIgnoreCase; Bucket[16] now parses as Bucket(16). Covered by test_parse_known_transforms_case_insensitively.
Transform::Unknown does not keep the original transform name, so writing table metadata loaded with a transform such as zorder or bucketv2[4] would replace it with "unknown". TableMetadata::write_to now fails instead. The check is not in Serialize for Transform, because FileScanTask serializes its partition spec and sort order. Also match transform names case-insensitively, as Java does. Co-authored-by: Claude Code <[email protected]>
Which issue does this PR close?
Transform::Unknown(String)API discussion and stays tracked there).What changes are included in this PR?
The V3 spec requires readers to read tables with unknown transforms, ignoring them.
FromStr for Transformreturned an error for any unrecognized transform name, so loading table metadata that uses a transform iceberg-rust does not know failed entirely.This changes parsing to match Java's
Transforms.fromString: a string that is not an exactly well-formed known transform parses asTransform::Unknowninstead of erroring. This covers unknown names (zorder), names sharing a prefix with known transforms (bucketv2[4]), malformed parameter shapes (bucket[abc], barebucket), and loose forms the previous parser accepted by accident (bucket10, previously parsed asBucket(10)). Well-formed parameters that overflowu32still error, matching Java's behavior for the equivalent input.Interaction with #2474 noted: that PR tightens parameter validation of known transforms; the two changes are semantically compatible (well-formed known-transform parameters are validated, everything else is unknown).
Writing table metadata that still holds a transform parsed as unknown fails with
FeatureUnsupported, becauseTransform::Unknowndoes not keep the original name and writing it would replace it with"unknown"; keeping the name is left to #2789. Transform names match case-insensitively, as in Java. Projecting_partitionandTransform::projectstill return an error for such tables.This is the Rust counterpart of the behavior proposed for PyIceberg in apache/iceberg-python#3630.
Are these changes tested?
Yes — new unit tests in
spec/transform.rs: known-transform parsing, the unknown fallback across nine unknown/malformed inputs, the overflow error case, and case-insensitive names; inspec/table_metadata.rs, two tests that load a spec or sort order usingzorder/bucketv2[4], apply a property change, and check that writing the metadata fails without creating a file.cargo test -p iceberg --lib spec::transform,cargo fmt --check, andcargo clippy -p iceberg --libpass locally.This pull request and its description were written by Claude Fable 5.