dongjoon-hyun opened a new pull request, #59602: URL: https://github.com/apache/spark/pull/59602
### What changes were proposed in this pull request? This PR aims to support the cast from `TIME(p)` to `TIME(q)` (`p < q`) in `UnwrapCastInBinaryComparison`. Like a decimal cast to a larger scale, this cast keeps the value, so the existing algorithm for numeric types is reused: the literal is truncated to `TIME(p)`, and the comparison is adjusted if the truncation drops digits. For a `TIME(6)` column `t`: | Before | After | |---|---| | `CAST(t AS TIME(9)) = TIME '12:00:00.100000000'` | `t = TIME '12:00:00.1'` | | `CAST(t AS TIME(9)) = TIME '12:00:00.100000001'` | `isnull(t) AND null` | | `CAST(t AS TIME(9)) < TIME '12:00:00.100000001'` | `t <= TIME '12:00:00.1'` | `In` and `InSet` are supported in the same way, including the DSv2 runtime `IN` filter (SPARK-59301). ### Why are the changes needed? When a `TIME(p)` column is compared with a value of a larger precision, type coercion casts the column (SPARK-57585), and the cast blocks the filter pushdown. For example, for a `TIME(6)` Parquet column `t`, `WHERE t = TIME '12:00:00.100000000'` pushes down only `IsNotNull(t)`, while `WHERE t = TIME '12:00:00.1'` pushes down `EqualTo(t,12:00:00.100)`. This was raised in the review of #59571. ### Does this PR introduce _any_ user-facing change? No. More filters on `TIME` columns are pushed down, and the query results are the same. ### How was this patch tested? Pass the CIs with the newly added test cases in `UnwrapCastInBinaryComparisonSuite`, `ParquetFilterSuite` and `DataSourceV2StrategySuite`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 -- 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]
