Skip to content

fix: unparse NULL nested-type literals as NULL - #27274

Open
vinycalves wants to merge 1 commit into
apache:mainfrom
vinycalves:fix/unparse-null-nested-literals
Open

vinycalves wants to merge 1 commit into
apache:mainfrom
vinycalves:fix/unparse-null-nested-literals

Conversation

@vinycalves

@vinycalves vinycalves commented Nov 9, 2026 •

Copy link
Copy Markdown

Which issue does this PR close?

Rationale

The unparser must produce SQL that preserves the meaning of the plan. A typed 'NULL' is still a null value, but nested types were handled through their children: a null list had no child values to render, so it became '[]', while struct, map, and union had no SQL rendering at all and returned an error. Both cases change the query or prevent it from being unparsed.

Fix

Nullness belongs to the value, not to its children. The scalar-to-SQL conversion now detects a null nested value before looking at its contents and emits the same 'NULL' literal used by every other typed null. Non-null nested values are unchanged and still return 'NotImplemented', because rendering them requires dialect-specific syntax.

Testing

The tests cover every affected type and the plan-to-SQL path. They also pin the behavior that must not change: an empty list stays '[]', a list with null elements keeps its elements, and a non-null struct still reports that it is unsupported.

'cargo test -p datafusion-sql' and
'cargo clippy -p datafusion-sql --all-targets --all-features -- -D warnings'
pass.
image

User-facing changes

Unparsed SQL now preserves null nested values instead of returning '[]' or an error. No API changes.

@github-actions github-actions Bot added the sql SQL Planner label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unparser turns NULL list literals into [] and fails on NULL struct/map literals

1 participant