harsh-ande opened a new pull request, #26127:
URL: https://github.com/apache/datafusion/pull/26127
## Which issue does this PR close?
- Closes #23889.
## Rationale for this change
Spark's `NextDay` casts its first argument to DATE, so
`next_day('2015-07-23', 'Mon')` and `next_day(TIMESTAMP '2015-07-23 12:12:12',
'Mon')` both work. `datafusion-spark` declared `Exact(Date32, Utf8)` and failed
at planning for STRING and TIMESTAMP inputs.
## What changes are included in this PR?
- `next_day` now uses a coercible signature: the first argument is
implicitly cast to DATE from STRING or TIMESTAMP, and the day-of-week is any
string type (numeric is still coerced to string).
- The kernel is unchanged.
- In `next_day.slt`, three existing `query error` expectations changed to
the new planner messages (arity and non-date first argument), and the
unparseable-string case now returns a cast error. They still fail at planning
or execution as before.
## What is the testing strategy for this PR?
New cases in `spark/datetime/next_day.slt`: string, string with a time part,
timestamp literal, string column with NULL, timestamp column, and
`LargeUtf8`/`Utf8View` day-of-week. I compared the expected results with
`pyspark==4.0.0`, ANSI on and off.
## Are there any user-facing changes?
`next_day` accepts more argument types. No API changes.
## Known limitations / unknowns
- An unparseable date string always errors. Spark returns NULL with ANSI
off and errors with ANSI on. This looks tied to the ANSI work in #23890 and
#23929.
- I did not verify timestamps with time zones near midnight against Spark's
session-time-zone cast.
- #23892 touches the same files, so I expect a small rebase if it merges
first.
- AI assistance was used to implement this. I reviewed and understand the
change, and checked the results against Spark.
--
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]