Fix ValuesExpression pruning dropping outer columns referenced from VALUES cells - #38779
Open
yvesleguennec wants to merge 2 commits into
Open
Fix ValuesExpression pruning dropping outer columns referenced from VALUES cells#38779yvesleguennec wants to merge 2 commits into
yvesleguennec wants to merge 2 commits into
Conversation
…ALUES cells - Visit nested RowValues/ValuesParameter in PruneValues so embedded ColumnExpressions are registered before outer join projections are pruned - Fix column-name backfill to use ColumnNames[j] instead of repeating the first unreferenced column's name Fixes dotnet#38700
Author
|
@dotnet-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Fixes VALUES pruning so nested outer-column references are retained.
Changes:
- Visits VALUES cells during pruning.
- Corrects pruned column-name backfilling.
- Adds relational regression coverage and a SQL Server baseline.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/EFCore.Relational/Query/SqlTreePruner.cs |
Corrects VALUES traversal and column pruning. |
test/EFCore.Relational.Specification.Tests/Query/AdHocQueryFiltersQueryRelationalTestBase.cs |
Adds the regression scenario. |
test/EFCore.SqlServer.FunctionalTests/Query/AdHocQueryFiltersQuerySqlServerTest.cs |
Verifies the generated SQL projection. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| referencedColumns[j] = true; | ||
| newColumnNames.Add(columnName); | ||
| newColumnNames.Add(values.ColumnNames[j]); |
Protects the case where leading VALUES columns stay referenced while a later column is pruned — the path that previously repeated the pruned column's name in newColumnNames.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #38700
SqlTreePruner.PruneValues(from #36159) copied VALUES row cells withoutVisit(), soColumnExpressions embedded in inline collections were neverregistered. Outer join projections were then over-pruned (e.g. only
Idprojected while
EXISTSstill referencedServiceId).Fix
Visit()nestedRowValues/ValuesParameterinPruneValues(same pattern as OpenJSON pruning)
ColumnNames[j]instead of repeating thefirst unreferenced column's name
Tests
ServiceIdremains in the join projectionNote: approach described on #38700; no maintainer reply after ~1.5 weeks, opening PR for review.