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

[3.1] Fix to #19825 - Query: incorrectly generating JOIN rather than APPLY for subqueries with outside references to a joined table #20064

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Feb 25, 2020

Description
During translation, when we decide whether we can apply JOIN or APPLY we visit inner SelectExpression looking for references to tables in the outer SelectExpression.
Problem was that we were using Contains method, which would not match cases where the outer table was in the form of JoinExpressionBase.
Fix is to use ContainsTableReference method which matches different types of tables.

Customer Impact
Invalid sql generated for relatively complicated but common query pattern. No easy workaround.

How found
Reported by multiple customers.

Test coverage
We have added test to cover this scenario.

Regression?
No.

Risk
Low. Fix is very isolated. Logic used to fix the issue is already being used in other places without problems. Quirk added.

…for subqueries with outside references to a joined table

During translation, when we decide whether we can apply JOIN or APPLY we visit inner SelectExpression looking for references to tables in the outer SelectExpression.
Problem was that we were using Contains method, which would not match cases where the outer table was in the form of JoinExpressionBase.
Fix is to use ContainsTableReference method which matches different types of tables.
@maumar maumar changed the title Fix to #19825 - Query: incorrectly generating JOIN rather than APPLY for subqueries with outside references to a joined table [3.1] Fix to #19825 - Query: incorrectly generating JOIN rather than APPLY for subqueries with outside references to a joined table Feb 25, 2020
@ajcvickers ajcvickers added this to the 3.1.x milestone Feb 29, 2020
@leecow leecow modified the milestones: 3.1.x, 3.1.4 Mar 5, 2020
@ajcvickers
Copy link
Member

Approved by tactics for 3.1.4. Wait for branch to open before merging.

@ajcvickers ajcvickers merged commit 094e427 into release/3.1 Apr 4, 2020
@ajcvickers ajcvickers deleted the fix19825_31 branch April 4, 2020 19:45
@ajcvickers ajcvickers removed this from the 3.1.4 milestone Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants