Skip to content

Fix to #30922 - Most cases of projecting a primitive collection don't work#31263

Merged
maumar merged 1 commit intomainfrom
fix30922_take2
Jul 21, 2023
Merged

Fix to #30922 - Most cases of projecting a primitive collection don't work#31263
maumar merged 1 commit intomainfrom
fix30922_take2

Conversation

@maumar
Copy link
Contributor

@maumar maumar commented Jul 14, 2023

Problem was that for cases that compose on the collection of primitives and then project it, we need identifier to properly bucket the results. On SqlServer we can use hidden key column that is a result of OPENJSON - we need something that is unique so we can't use the value itself. Fix is to add identifier to the SelectExpression based on OPENJSON and also modify the logic that figures out if we need key (and thus need to revert to OPENJSON without WITH clause). Also some minor fixes around nullability - when projecting element of a collection of primitives using OUTER APPLY/JOIN we must set the projection binding to nullable, as the value can always be null, in case of empty collection.

Fixes #30922

@maumar maumar requested a review from roji July 14, 2023 01:56
@maumar maumar force-pushed the fix30922_take2 branch 3 times, most recently from e0f63d9 to 80fc576 Compare July 16, 2023 03:04
@maumar
Copy link
Contributor Author

maumar commented Jul 16, 2023

@roji ready for review

@maumar maumar force-pushed the fix30922_take2 branch 3 times, most recently from 0b378ce to 0bd9057 Compare July 19, 2023 00:25
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maumar, looking good! Mainly nits below.

… work

Problem was that for cases that compose on the collection of primitives and then project it, we need identifier to properly bucket the results. On SqlServer we can use hidden key column that is a result of OPENJSON - we need something that is unique so we can't use the value itself.
Fix is to add identifier to the SelectExpression based on OPENJSON and also modify the logic that figures out if we need key (and thus need to revert to OPENJSON without WITH clause). Also some minor fixes around nullability - when projecting element of a collection of primitives using OUTER APPLY/JOIN we must set the projection binding to nullable, as the value can always be null, in case of empty collection.

Fixes #30922
@maumar maumar merged commit 6534e63 into main Jul 21, 2023
@maumar maumar deleted the fix30922_take2 branch July 21, 2023 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Most cases of projecting a primitive collection don't work

2 participants