Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Fix to #32023 - Case expressions may only be nested to level 10 when using SplitQuery() or ToList() inside projection. #32094

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Oct 19, 2023

Problem was that our SqlExpression simplifying visitor, when visiting ShapedQuery would only look into QueryExpression part. This makes sense in general as QueryExpression is where the SqlExpression is stored. However, for split query scenarios, we also have SqlExpression in the ShaperExpression (wrapped by RelationalSplitCollectionShaperExpression), and all the optimizations were not run on that SqlExpression piece, which in that case caused too deep CASE WHEN ELSE structure (that we normally optimize into flat CASE with multiple WHENs.

Fix is to also visit ShaperExpression when performing post processing.

Fixes #32023

…using SplitQuery() or ToList() inside projection.

Problem was that our SqlExpression simplifying visitor, when visiting ShapedQuery would only look into QueryExpression part. This makes sense in general as QueryExpression is where the SqlExpression is stored. However, for split query scenarios, we also have SqlExpression in the ShaperExpression (wrapped by RelationalSplitCollectionShaperExpression), and all the optimizations were not run on that SqlExpression piece, which in that case caused too deep CASE WHEN ELSE structure (that we normally optimize into flat CASE with multiple WHENs.

Fix is to also visit ShaperExpression when performing post processing.

Fixes #32023
@maumar maumar requested a review from roji October 19, 2023 06:47
@maumar maumar merged commit 7112c2b into main Oct 24, 2023
7 checks passed
@maumar maumar deleted the fix32023_main branch October 24, 2023 06:46
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.

Case expressions may only be nested to level 10 when using SplitQuery() or ToList() inside projection.
2 participants