Adam-Alani opened a new pull request, #23997:
URL: https://github.com/apache/datafusion/pull/23997
## Why
`date_part` currently determines its return field before constant folding
runs, so a valid constant expression such as `CAST('epoch' AS VARCHAR)` is
rejected because it is not a direct literal. This change is stacked on #22851,
which makes the function's return type value-independent and
PostgreSQL-compatible.
## What
This allows foldable constant expressions in the first argument of
`date_part` while preserving runtime validation that the evaluated value is a
non-null scalar string. It adds regression coverage for a casted `epoch`
argument and updates type expectations added since #22851 was opened.
## How
Return-field inference now uses only the temporal argument's nullability and
always reports `Float64`; it no longer inspects the unsimplified first
argument. The normal expression simplifier can therefore fold casts and other
constant expressions before execution, where the existing scalar-value
validation still applies.
Validated with:
`cargo test --test sqllogictests -p datafusion-sqllogictest --
datetime/date_part.slt`
Depends on #22851.
--
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]