adriangb commented on PR #23729: URL: https://github.com/apache/datafusion/pull/23729#issuecomment-5027028838
Updated: the reverse (narrowing) direction was unsound and is now blocked. `cast(date64_col AS Date32) op lit` casts the column down by truncating milliseconds to the day (many-to-one), so `cast(date64 AS Date32) = <day>` matches any millisecond within that day, while unwrapping to `date64 = <midnight ms>` matches only midnight. Since Arrow does not require Date64 values to be whole days (arrow-rs#5288), the column can hold sub-day values the planner can't see, and the rewrite would drop those rows. This PR now only unwraps the **widening** `Date32 -> Date64` column cast, which is injective and sound (the Date64 literal is still checked for whole-day exactness, else left as-is). A new `is_date_narrowing_cast` guard blocks `Date64 -> Date32`, mirroring the existing `is_timestamp_precision_narrowing_cast`. Retitled accordingly. -- 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]
