Repository navigation
fix: unparse NULL nested-type literals as NULL - #27274
Open
vinycalves wants to merge 1 commit into
Open
vinycalves wants to merge 1 commit into
vinycalves wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
[]and fails on NULL struct/map literals #26316.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.
User-facing changes
Unparsed SQL now preserves null nested values instead of returning '[]' or an error. No API changes.