Pastoray commented on PR #429:
URL: https://github.com/apache/datafusion-spark/pull/429#issuecomment-7243309057
Thanks for picking this up, and for the thorough description. I checked out
`78dd0c6` and ran fmt, strict clippy, the `date_part` unit tests and the full
sqllogictest suite in both modes. All pass locally. I tried a few extra cases
and have two main concerns, plus smaller notes.
**1. The exact repro from #375 still doesn't match through SQL**
```
SELECT date_part('QUARTERS'::string, '2000-01-01'::date);
Error during planning: [INVALID_EXTRACT_FIELD] Cannot extract `QUARTERS`
from "Utf8("2000-01-01")". SQLSTATE: 42601
```
The issue expects `… from DATE '2000-01-01'`. I know the description says
casts and compound expressions may keep DataFusion's notation, but this is the
headline literal case, and the SQL-style `DATE '…'` / `TIMESTAMP '…'` output
only appears on the direct `invoke_with_args` path (e.g. `TIMESTAMP '2000-01-01
12:30:45'` through SQL also gives `Utf8("2000-01-01 12:30:45")`). Would it be
feasible to recover the literal when the argument is a cast of a literal in
`simplify` / `return_field_from_args`? If not, it would help to say in the PR
and #375 that the SQL-style form is physical-path only.
**2. The slt assertions are looser than the repo convention**
In #336, @andygrove asked for planning-time error cases to assert the full
expected output, and `parse_url.slt` does so. The new records, such as `query
error INVALID_EXTRACT_FIELD.*Cannot extract `QUARTERS`.*2000-01-01.*42601`,
pass for both `DATE '2000-01-01'` and `Utf8("2000-01-01")`, so they don't pin
the format #375 is about. Could they assert the complete message?
**3. Quoting (question)**
The message wraps the source in double quotes (`from "DATE '2000-01-01'"`),
while #375 and the #336 review discussion show no quotes. You mention checking
against Spark 4.2.0. Is the quoted form what it emits? If so, a note in the PR
would settle it. Either way, the SQL path currently nests quotes: `"Utf8("…")"`.
**4. Debug formatting can leak (non-blocking)**
`source_argument` falls back to `{value:?}`. Calling `invoke_with_args`
directly I got:
- tz-aware timestamp: `from "TimestampMicrosecond(946729845000000,
Some("UTC"))"`
- `Date64`: `from "Date64("2000-01-01")"`
- string: `from "Utf8("2000-01-01")"`
Perhaps handle timestamps with a timezone, or at least avoid Rust Debug
output in user-facing errors.
**5. Nit**
`return_field_from_args` indexes `scalar_arguments[1]` and `arg_fields[1]`
directly. `.get(1)` or `take_function_args` would turn a malformed direct call
into an error rather than a panic. The signature may already rule this out, so
this is only defensive.
The approach looks right. Happy to re-test after updates.
--
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]