discord9 opened a new pull request, #22837: URL: https://github.com/apache/datafusion/pull/22837
## Which issue does this PR close? Part of https://github.com/GreptimeTeam/greptimedb/issues/8214. Follow-up / smaller alternative to #21908. ## Rationale for this change `unwrap_cast` can currently rewrite predicates like: ```sql CAST(ts_ns AS timestamp(3)) = timestamp(3) '2024-01-01 00:00:00.001' ``` into an equality against the original nanosecond column. That is not equivalent: the original predicate matches every nanosecond timestamp within the same millisecond, while the rewritten predicate only matches the exact millisecond boundary. ## What changes are included in this PR? This is intentionally a small blocklist-only fix: - add a shared `is_timestamp_precision_narrowing_cast` helper - block comparison cast unwrap when a timestamp cast narrows precision - apply the same guard to logical and physical unwrap-cast simplifiers - keep timestamp precision widening unwraps enabled ## Are these changes tested? Added targeted logical, physical, and helper tests. Ran: ```text cargo test -p datafusion-optimizer unwrap_cast cargo test -p datafusion-physical-expr unwrap_cast cargo test -p datafusion-expr-common test_timestamp_precision_narrowing_cast ``` ## Are there any user-facing changes? Plans will keep timestamp precision-narrowing casts in comparison predicates instead of unwrapping them incorrectly. -- 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]
