sdf-jkl opened a new pull request, #27377: URL: https://github.com/apache/datafusion/pull/27377
## Which issue does this PR close? - Closes #27359. ## Rationale for this change Queries that compare, join, or union time values with different units fail during planning. For example, a Parquet `TIME(MICROS)` column (`Time64(µs)`) cannot be compared with a `TIME` literal (`Time64(ns)`): ``` Cannot infer common argument type for comparison operation Time64(µs) = Time64(ns) ``` Since #27316, SQL types alone hit this too, for example a `TIME(6)` column compared with `TIME '12:00:00'`. #27316 has been requested for 56, so this fix should go with it. ## What changes are included in this PR? `temporal_coercion` gets a rule for two time types. It picks the finer unit with `timeunit_coercion`, the helper timestamps already use, and returns `Time32` for seconds and milliseconds or `Time64` for microseconds and nanoseconds. Comparison, `IN`, join, `UNION`, `CASE`, and `coalesce` coercion all reach this function. `Time - Time` is unchanged because `temporal_math_coercion` handles it before this rule. ## What is the testing strategy for this PR? New cases in `datafusion/sqllogictest/test_files/datetime/timestamps.slt` cover `=`, `<`, `IN`, `JOIN`, `UNION ALL`, and `coalesce` across all six pairs of distinct units. They also check that the coarser value is widened rather than the finer one truncated: a `TIME(6)` value of `12:34:56.123456` compares less than a `TIME` value of `12:34:56.123456789`. All new cases fail without the change. Validation passed: the full sqllogictest suite, lib and integration tests for `datafusion-expr-common`, `datafusion-expr`, `datafusion-optimizer`, and `datafusion-sql`, `cargo fmt --check`, and Clippy on `datafusion-expr-common`. Full workspace tests were not run. ## Are there any user-facing changes? Yes. Comparisons, joins, unions, and `coalesce` between time values with different units now plan and return results, with both sides cast to the finer unit. No public API changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
