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

[SMALL] Fix to #30273 - EF7 generating incorrect SQL for the Concat/Union All #30452

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Mar 10, 2023

Problem was that during SelectExpression pruning for set operations we would try to prune both sources independently. However, if a source is Distinct we can't prune (that could affect the result). So the problematic case is where we prune one source but can't prune the second due to Distinct, and we end up with both sources having not matching projections. Fix is to check if either source has Distinct before attempting to prune them.

Fixed #30273

…, The same code was working fine for EF6.4.4

Problem was that during SelectExpression pruning for set operations we would try to prune both sources independently. However, if a source is Distinct we can't prune (that could affect the result). So the problematic case is where we prune one source but can't prune the second due to Distinct, and we end up with both sources having not matching projections. Fix is to check if either source has Distinct before attempting to prune them.

Fixed #30273
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.

Not sure exactly what pruning means but 🐑 🇮🇹

@maumar
Copy link
Contributor Author

maumar commented Mar 10, 2023

@roji it's removing the unused columns from projection

select x.Name From (Select a.Id, a.Name, a.Date FROM MyTable as a) as x, we only need name so can "prune" Id and Date from inner select

@roji
Copy link
Member

roji commented Mar 10, 2023

Thanks for the explanation @maumar, makes sense!

@maumar maumar merged commit 1c88175 into main Mar 10, 2023
@maumar maumar deleted the fix30273 branch March 10, 2023 23:30
@ajcvickers ajcvickers changed the title [SMALL] Fix to #30273 - EF7 generating incorrect SQL for the Concat/Union All, The same code was working fine for EF6.4.4 [SMALL] Fix to #30273 - EF7 generating incorrect SQL for the Concat/Union All Mar 16, 2023
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.

EF7 generating incorrect SQL for the Concat/Union All
2 participants