mohammadsubhani opened a new pull request, #57489:
URL: https://github.com/apache/spark/pull/57489
### What changes were proposed in this pull request?
This PR changes `ToTime` to return a null literal typed as `TimeType` when
its
foldable format argument evaluates to null.
It also adds regression coverage for SQL and Column API calls. The shared
test
runs with both ANSI mode enabled and disabled.
### Why are the changes needed?
When a foldable null format was provided, `ToTime` created its null result
using
the format expression's data type. Since the format argument is a string
expression, the result was incorrectly typed as `STRING` instead of `TIME`.
`to_time` must preserve its declared `TIME` result type even when the format
argument causes the result value to be null.
### Does this PR introduce _any_ user-facing change?
Yes. For expressions such as `to_time('00:00:00', NULL)`, the result value
remains null, but its schema is now correctly reported as `TIME` instead of
`STRING`.
### How was this patch tested?
Added a regression test and ran it in both ANSI configurations:
```bash
build/sbt \
'sql/testOnly org.apache.spark.sql.TimeFunctionsAnsiOnSuite -- -z
"SPARK-58296"' \
'sql/testOnly org.apache.spark.sql.TimeFunctionsAnsiOffSuite -- -z
"SPARK-58296"'
```
Both tests passed.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-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]