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

[release/3.1] Query: Map projection properly when joining 2 tables #20207

Merged
merged 1 commit into from
Mar 22, 2020

Conversation

smitpatel
Copy link
Member

@smitpatel smitpatel commented Mar 7, 2020

When joining 2 tables in relational, we lift the table from inner select expression and copy over projections. If one of this projection is same as any outer projection then we reuse the same projection. That means the associated indexes in inner shaper will go to different indexes rather than in linear fashion.

Fix is to remember which index each projection went and use that rather than applying an offset.

Resolves #19616

Description

Inside Select, if subquery Select contains a constant/parameter, which is in parent Select or other subquery's Select then we project it only once in SQL causing projection indexes mismatch.

Customer Impact

Problematic queries throws exception.

How found

Reported by multiple customers.

Test coverage

Added regression test for scenario in which projection indexes would become non-linear.

Regression?

Yes. From 2.2 to 3.0

Risk

Low. The modified codepath is being used in more than 15,000 tests. It properly takes care of existing working scenarios.

When joining 2 tables in relational, we lift the table from inner select expression and copy over projections. If one of this projection is same as any outer projection then we reuse the same projection. That means the associated indexes in inner shaper will go to different indexes rather than in linear fashion.
Fix is to remember which index each projection went and use that rather than applying an offset.

Resolves #19616
@smitpatel smitpatel added this to the 3.1.x milestone Mar 7, 2020
@ajcvickers
Copy link
Member

ajcvickers commented Mar 9, 2020

Quirk?

@jamshedd
Copy link
Member

Approved for 3.1.4.

@ajcvickers
Copy link
Member

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

@smitpatel smitpatel changed the base branch from release/3.1 to release/3.1.4 March 21, 2020 21:36
@smitpatel smitpatel merged commit c9ca4f4 into release/3.1.4 Mar 22, 2020
@smitpatel smitpatel deleted the smit/constantlifting branch March 22, 2020 04:07
@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.

ArgumentOutOfRangeException upon certain queries with includes
4 participants