jayzhan211 commented on code in PR #26452:
URL: https://github.com/apache/datafusion/pull/26452#discussion_r4434159595


##########
datafusion/pruning/src/pruning_predicate.rs:
##########
@@ -1349,6 +1349,16 @@ fn verify_support_type_for_prune(from_type: &DataType, 
to_type: &DataType) -> Re
         }
         _ => to_type,
     };
+    // Casting a timestamp to a time-of-day wraps at midnight and does not
+    // preserve ordering across day boundaries. Casting timestamp min/max
+    // statistics could therefore produce invalid bounds and prune matches.

Review Comment:
   @rgbuilds thanks for the fix! The root cause is that pruning has its own 
order check that allows any cast unless exactly one side is a string, instead 
of asking `is_order_preserving_cast` in 
`physical-expr/src/expressions/cast.rs`, which already rejects this cast. So 
similar casts still drop rows here, e.g. `CAST(i AS BOOLEAN)` and `CAST(i AS 
BYTEA)` (#26981). #26982 moves pruning onto that shared rule and will replace 
this arm, so this is fine to merge as the fix for #26451.



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