kosiew commented on code in PR #23727:
URL: https://github.com/apache/datafusion/pull/23727#discussion_r3636507350


##########
datafusion/sqllogictest/test_files/simplify_expr.slt:
##########
@@ -146,3 +146,23 @@ logical_plan
 physical_plan
 01)ProjectionExec: expr=[column1@0 = 1 as opt1, column1@0 = 2 AND column1@0 != 
2 as noopt1, column1@0 = 4 as opt2, column1@0 != 5 AND column1@0 = 5 as noopt2]
 02)--DataSourceExec: partitions=1, partition_sizes=[1]
+
+# Identity Date cast in a comparison predicate.
+# `cast(d AS date)` where `d` is already Date32 is an identity cast and should
+# fold away, so the predicate compares against the bare column `d`. This 
enables
+# downstream pruning / filter pushdown that expects a bare-column comparison.
+statement ok
+create table dates(d date) as values (DATE '2024-01-01'), (DATE '2024-01-02');
+
+query TT
+explain select d from dates where cast(d as date) = DATE '2024-01-01';

Review Comment:
   Nice addition! One optional follow-up would be to add an `IN` predicate 
regression, for example `cast(d AS date) IN (DATE '2024-01-01')`. `IN` goes 
through a separate validation and rewrite path that also relies on the same 
literal-cast helper, so this would help extend the date-specific integration 
coverage beyond binary comparisons.



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