yadavay-amzn commented on code in PR #16074:
URL: https://github.com/apache/iceberg/pull/16074#discussion_r3164339282


##########
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:
   @ebyhr I was able to confirm that the test fails without the fix and passes 
with it.                                                                        
                                                                                
                                         
   
   Without the fix, `Projections.inclusive(spec).project(hourFilter)` returns 
`ref(name="ts") == 490674`; an invalid predicate that binds an integer literal 
to a timestamptz field. The `ValidationException` from the original issue 
occurs downstream when this invalid predicate is evaluated against manifest 
data.                                                                           
                                                        
   
   Our test catches the bug at the projection level (wrong predicate returned 
instead of `alwaysTrue`), which is the root cause.



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

Reply via email to