doc: Add documentation explaining the behavior of null values in struct comparisons#21226
doc: Add documentation explaining the behavior of null values in struct comparisons#21226xiedeyantu wants to merge 3 commits intoapache:mainfrom
null values in struct comparisons#21226Conversation
…struct comparisons
null values in …null values in struct comparisons
asolimando
left a comment
There was a problem hiding this comment.
LGTM: only one minor comment but the extra doc is already very helpful
| For tuple-like values, `IN` uses DataFusion's struct equality semantics: | ||
|
|
||
| ```sql | ||
| SELECT (7521, 30) IN ((7521, NULL)); |
There was a problem hiding this comment.
Maybe an example retuning true involving a comparison with NULL elements (like that of line 227 above), which is probably the most surprising result if one expects standard SQL semantics. WDYT?
There was a problem hiding this comment.
I think it would be helpful to add this in. Please feel free to let me know if anything else needs to be added. This way, users can quickly understand the differences involved.
comphead
left a comment
There was a problem hiding this comment.
Thanks @xiedeyantu it would be great also to include a link to this section into a doc describing the struct builtin function
@comphead Thanks for your reply! I have added a link to struct function. Please review again if it looks well for you. |
Which issue does this PR close?
Rationale for this change
DataFusion already supports tuple-like and
STRUCTcomparisons, but the user-facing documentation did not clearly describe the current comparison semantics, especially around lexicographical ordering andNULLhandling. TheINdocumentation also did not explain tuple-like values.What changes are included in this PR?
STRUCTcomparison note to struct_coercion.md, documenting that:STRUCTvalues support standard comparison operatorsNULLis ordered before non-NULLSTRUCTcomparisons, including aNULLexampleINuses DataFusion's struct equality semanticsSELECT (7521, 30) IN ((7521, NULL));falseAre these changes tested?
No new tests were added. This PR only updates documentation for existing behavior, and the documented behavior is already covered by existing tuple/struct comparison and
INtests.Are there any user-facing changes?
Yes. This PR updates the SQL user documentation to clarify the current semantics of
STRUCTcomparisons and tuple-likeINexpressions.