Skip to content

Parse unrecognized transform names as Transform::Unknown - #2790

Open
moomindani wants to merge 3 commits into
apache:mainfrom
moomindani:unknown-transform-parse-fallback
Open

moomindani wants to merge 3 commits into
apache:mainfrom
moomindani:unknown-transform-parse-fallback

Conversation

@moomindani

@moomindani moomindani commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

What changes are included in this PR?

The V3 spec requires readers to read tables with unknown transforms, ignoring them. FromStr for Transform returned 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 as Transform::Unknown instead of erroring. This covers unknown names (zorder), names sharing a prefix with known transforms (bucketv2[4]), malformed parameter shapes (bucket[abc], bare bucket), and loose forms the previous parser accepted by accident (bucket10, previously parsed as Bucket(10)). Well-formed parameters that overflow u32 still 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, because Transform::Unknown does 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 _partition and Transform::project still 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; in spec/table_metadata.rs, two tests that load a spec or sort order using zorder / 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, and cargo clippy -p iceberg --lib pass locally.

This pull request and its description were written by Claude Fable 5.

@moomindani

Copy link
Copy Markdown
Contributor Author

Gentle ping — this has been open for ~3 weeks with CI green and no review yet.

It's a small, self-contained change: FromStr for Transform currently errors on any unrecognized transform name, but the v3 spec requires readers to read tables with unknown transforms and ignore them, so a table using a transform this version doesn't know about is unreadable today. One file, spec/transform.rs.

Scoped deliberately to the non-breaking subset — preserving the original name for round-trip needs a Transform::Unknown(String) API discussion, which stays in #2789.

@blackmwk you've reviewed most of the recent spec changes — would you mind taking a look when you have a moment? Part of #2411.

@moomindani
moomindani force-pushed the unknown-transform-parse-fallback branch from af9372b to 0823b86 Compare August 21, 2026 16:26
@moomindani
moomindani force-pushed the unknown-transform-parse-fallback branch from 0823b86 to 56aca78 Compare September 15, 2026 23:39
@moomindani

Copy link
Copy Markdown
Contributor Author

Rebased onto current main — this had drifted 85 commits behind and was conflicting, so no CI had run on it for weeks. Now mergeable and green.

Verified locally with the pinned toolchain: cargo test -p iceberg --lib 1750 passed, cargo clippy --all-targets --all-features -- -D warnings clean, cargo fmt --check clean. The rebase conflict was only in the test module, where main and this branch had each appended tests at the same place; both sets are kept.

@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 Transforms.fromString. It has had no review since it was opened on 9 July. Would either of you take a look?

@mfellner mfellner mentioned this pull request Oct 11, 2026
22 of 64 tasks
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the stale label Oct 16, 2026
@moomindani
moomindani force-pushed the unknown-transform-parse-fallback branch from 56aca78 to 47398ef Compare October 16, 2026 08:00
@moomindani

Copy link
Copy Markdown
Contributor Author

Not stale. Rebased onto current main again to clear a conflict with the invalid_data! macro from #2928; the parameter-parsing helper now uses it too. cargo test -p iceberg --lib 1978 passed, clippy and fmt clean, public API unchanged.

@laskoviymishka you reviewed and merged the recent spec/transform.rs changes (#2928, #3243); would you take a look? It is one file.

@github-actions github-actions Bot removed the stale label Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the stale label Nov 17, 2026
@laskoviymishka
laskoviymishka self-requested a review November 17, 2026 16:02
@github-actions github-actions Bot removed the stale label Nov 18, 2026
moomindani and others added 2 commits November 21, 2026 01:02
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.
@moomindani
moomindani force-pushed the unknown-transform-parse-fallback branch from 47398ef to ca2fbce Compare November 20, 2026 16:09

@laskoviymishka laskoviymishka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants