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

Query: Flatten out TPC union tables in join #28009

Closed
smitpatel opened this issue May 11, 2022 · 0 comments · Fixed by #28142
Closed

Query: Flatten out TPC union tables in join #28009

smitpatel opened this issue May 11, 2022 · 0 comments · Fixed by #28142
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@smitpatel
Copy link
Contributor

Test: Correlated_collections_different_collections_projected

SELECT [t].[Nickname], [t].[SquadId], [t0].[Name], [t0].[IsAutomatic], [t0].[Id], [t1].[Nickname], [t1].[Rank], [t1].[SquadId]
FROM (
    SELECT [o].[Nickname], [o].[SquadId], [o].[FullName]
    FROM [Officers] AS [o]
) AS [t]
LEFT JOIN (
    SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName]
    FROM [Weapons] AS [w]
    WHERE [w].[IsAutomatic] = CAST(1 AS bit)
) AS [t0] ON [t].[FullName] = [t0].[OwnerFullName]
LEFT JOIN (
-- HERE
    SELECT [t2].[Nickname], [t2].[Rank], [t2].[SquadId], [t2].[FullName], [t2].[LeaderNickname], [t2].[LeaderSquadId]
    FROM (
        SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank]
        FROM [Gears] AS [g0]
        UNION ALL
        SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank]
        FROM [Officers] AS [o0]
    ) AS [t2]
-- HERE
) AS [t1] ON [t].[Nickname] = [t1].[LeaderNickname] AND [t].[SquadId] = [t1].[LeaderSquadId]
ORDER BY [t].[FullName], [t].[Nickname], [t].[SquadId], [t0].[Id], [t1].[FullName], [t1].[Nickname]

Since there are no additional components we can lift it. Currently we fail to because the order of projection has changed. (this could have side-effects of reading wrong data, need to verify).
The order of projection changed due to client projection + collection projection.
First columns from user defined projection added then identifier for collection result added then ordering specified on inner for collection projection added then join columns added.

@AndriySvyryd AndriySvyryd added this to the Backlog milestone May 13, 2022
@smitpatel smitpatel modified the milestones: Backlog, 7.0.0 Jun 1, 2022
@smitpatel smitpatel self-assigned this Jun 1, 2022
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 1, 2022
smitpatel added a commit that referenced this issue Jun 1, 2022
- Apply pruning on subqueries in set operation when not distinct
- Avoid table aliases which would be pruned in TPC later
- Avoid push down when left-joining with TPC select expression

Resolves npgsql/efcore.pg#2387
Resolves #28009
smitpatel added a commit that referenced this issue Jun 1, 2022
- Apply pruning on subqueries in set operation when not distinct
- Avoid table aliases which would be pruned in TPC later
- Avoid push down when left-joining with TPC select expression

Resolves npgsql/efcore.pg#2387
Resolves #28009
smitpatel added a commit that referenced this issue Jun 1, 2022
- Apply pruning on subqueries in set operation when not distinct
- Avoid table aliases which would be pruned in TPC later
- Avoid push down when left-joining with TPC select expression

Resolves npgsql/efcore.pg#2387
Resolves #28009
@ghost ghost closed this as completed in #28142 Jun 2, 2022
ghost pushed a commit that referenced this issue Jun 2, 2022
- Apply pruning on subqueries in set operation when not distinct
- Avoid table aliases which would be pruned in TPC later
- Avoid push down when left-joining with TPC select expression

Resolves npgsql/efcore.pg#2387
Resolves #28009
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview6 Jun 20, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview6, 7.0.0 Nov 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants