yadavay-amzn commented on code in PR #16074:
URL: https://github.com/apache/iceberg/pull/16074#discussion_r3121079899
##########
api/src/test/java/org/apache/iceberg/transforms/TestProjection.java:
##########
@@ -394,4 +394,27 @@ 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
+ Schema schema =
+ new Schema(
+ required(1, "id", Types.LongType.get()),
+ required(2, "ts", Types.TimestampType.withZone()));
+
+ PartitionSpec spec =
PartitionSpec.builderFor(schema).identity("ts").build();
+
+ Expression hourFilter = equal(hour("ts"), 490674);
+ Expression projected = Projections.inclusive(spec).project(hourFilter);
+
+ // The identity transform cannot project a hours-transform predicate, so
it should
+ // be replaced with alwaysTrue (inclusive) rather than throwing
ValidationException
+ assertThat(projected).isEqualTo(Expressions.alwaysTrue());
Review Comment:
The exception is caught internally by the projection framework and converted
to `alwaysTrue`/`alwaysFalse`. Without the fix, `projectStrict()` creates an
`UnboundPredicate` with an integer literal for a timestamptz field, which fails
during binding — the test assertion fails because the projection result is
neither `alwaysTrue` nor `alwaysFalse`. Updated the comments to explain this
more clearly.
--
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]