shrirangmhalgi opened a new pull request, #56637: URL: https://github.com/apache/spark/pull/56637
### What changes were proposed in this pull request? Extend `DateFormatClass` (used by `to_char` / `to_varchar` / `date_format`) to accept `TimeType` input. When the input is `TimeType`, the expression uses `TimeFormatter` to format the time-of-day value instead of `TimestampFormatter`. Date-only pattern fields (e.g., `yyyy-MM-dd`) are rejected at runtime with a clear error. ### Why are the changes needed? to_char and to_varchar accept DateType and TimestampType but not TimeType. With the TIME data type now supported in Spark, users need a way to format time values to strings using standard datetime patterns (e.g., `to_char(time_col, 'HH:mm:ss')`). ### Does this PR introduce _any_ user-facing change? Yes. `to_char(time_value, format)` and `to_varchar(time_value, format)` now work for TimeType inputs, formatting time-of-day fields (HH, mm, ss, fractional seconds). Passing date-only patterns to a TIME input raises an error. ### How was this patch tested? - Unit tests in `DateExpressionsSuite` (formatting, null handling, date-pattern rejection) - SQL golden file tests in `datetime-formatting.sql` verifying `to_char` and `to_varchar` with TIME literals - All existing `DateFormat` tests pass (no regressions) ### Was this patch authored or co-authored using generative AI tooling? Yes. Co-Authored using Claude Opus 4.6 -- 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]
