-
Notifications
You must be signed in to change notification settings - Fork 3.2k
API: Fix Identity projection for mismatched transform types (#15502) #16074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -394,4 +394,30 @@ public void testProjectionNames() { | |
| Projections.inclusive(partitionSpec).project(equal(truncate("string", 10), "abc")); | ||
| assertThat(predicate.ref().name()).isEqualTo("string_trunc"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testIdentityProjectionWithTransformPredicate() { | ||
| // Regression test for https://github.com/apache/iceberg/issues/15502 | ||
| // Identity-partitioned timestamptz field filtered with hours() should not throw | ||
| // ValidationException when projecting the predicate. | ||
| Schema schema = | ||
| new Schema( | ||
| required(1, "id", Types.LongType.get()), | ||
| required(2, "ts", Types.TimestampType.withZone())); | ||
|
|
||
| PartitionSpec spec = PartitionSpec.builderFor(schema).identity("ts").build(); | ||
|
|
||
| // hours(ts) = 490674 produces an integer literal that cannot bind to timestamptz. | ||
| // Without the fix, projectStrict() attempts to create an UnboundPredicate with the | ||
| // integer literal for a timestamptz field, which fails during binding. | ||
| Expression hourFilter = equal(hour("ts"), 490674); | ||
|
|
||
| // Inclusive projection: cannot project → falls back to alwaysTrue | ||
| Expression projected = Projections.inclusive(spec).project(hourFilter); | ||
| assertThat(projected).isEqualTo(Expressions.alwaysTrue()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ValidationException isn't thrown in this test even if I revert a change of Identity.java.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exception is caught internally by the projection framework and converted to |
||
|
|
||
| // Strict projection: cannot project → falls back to alwaysFalse | ||
| Expression strictProjected = Projections.strict(spec).project(hourFilter); | ||
| assertThat(strictProjected).isEqualTo(Expressions.alwaysFalse()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence looks incomplete. "... should not throw ValidationException"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed — completed the sentence.