akoshchiy commented on code in PR #26989:
URL: https://github.com/apache/datafusion/pull/26989#discussion_r4647716835


##########
datafusion/sqllogictest/test_files/simplify_expr.slt:
##########
@@ -1099,3 +1099,132 @@ drop table cast_preimage_tz;
 
 statement ok
 drop table cast_preimage_tz_ms;
+
+# Date32 -> timestamp: midnight literals unwrap to a date comparison.
+statement ok
+CREATE TABLE cast_preimage_date32 AS
+SELECT id, arrow_cast(v, 'Date32') AS d
+FROM (VALUES (1, -2), (2, -1), (3, 0), (4, 1), (5, 2), (6, NULL)) AS t(id, v);
+
+query TT
+EXPLAIN SELECT * FROM cast_preimage_date32
+WHERE CAST(d AS TIMESTAMP(0)) = arrow_cast(-86400, 'Timestamp(s)');
+----
+logical_plan
+01)Filter: cast_preimage_date32.d = Date32("1969-12-31")
+02)--TableScan: cast_preimage_date32 projection=[id, d]
+physical_plan
+01)FilterExec: d@1 = 1969-12-31
+02)--DataSourceExec: partitions=1, partition_sizes=[1]
+
+# A non-midnight literal rounds up to the next day, including before the epoch.
+query TT
+EXPLAIN SELECT * FROM cast_preimage_date32
+WHERE TIMESTAMP '1969-12-31 23:59:59.999999999' < d;
+----
+logical_plan
+01)Filter: cast_preimage_date32.d >= Date32("1970-01-01")
+02)--TableScan: cast_preimage_date32 projection=[id, d]
+physical_plan
+01)FilterExec: d@1 >= 1970-01-01
+02)--DataSourceExec: partitions=1, partition_sizes=[1]
+
+# IN lists use the exact-preimage path rather than the comparison range path.
+query TT

Review Comment:
   done



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