fixfon opened a new pull request, #26722:
URL: https://github.com/apache/datafusion/pull/26722
## Which issue does this PR close?
- Closes #26316.
## Rationale for this change
The unparser turns a NULL list literal into `[]`, so the SQL it writes is a
different value from the plan (a NULL `FixedSizeList` came out as `[NULL,
NULL]`). A NULL struct, map or union literal fails with
`NotImplemented("Unsupported scalar")`, so a plan that contains one can't be
unparsed at all.
## What changes are included in this PR?
`scalar_to_sql` now catches a NULL list, struct, map or union first and
writes `NULL`, the same bare `NULL` the other typed nulls already use. Non-null
values are handled as before, so a non-null struct, map or union still returns
`NotImplemented`.
## What is the testing strategy for this PR?
Two unit tests in `unparser/expr.rs`, through `expr_to_sql` (sqllogictest
can't reach the unparser). One checks that a NULL of each of the eight types
gives `NULL`, and that a list holding a NULL list gives `[NULL, [1]]`. The
other checks that an empty list is still `[]` and a non-null struct still
returns `NotImplemented`. The first test fails on main with eight wrong results
and passes with the change. `cargo test -p datafusion-sql` passes.
Not covered: a union whose active value is NULL, a NULL list wrapped in a
dictionary, and non-default dialects. The bare `NULL` has no type, so a target
engine may infer a different one.
## Are there any user-facing changes?
Unparsed SQL now has `NULL` where it used to have `[]`, or an error. No API
changes.
AI assistance: Claude (via T3 Code) helped write the change and the test.
--
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]