-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Prune SQL Server OPENJSON's WITH clause #32673
Conversation
[OwnedCollectionBranch] nvarchar(max) '$.OwnedCollectionBranch' AS JSON, | ||
[OwnedReferenceBranch] nvarchar(max) '$.OwnedReferenceBranch' AS JSON | ||
) AS [o] | ||
FROM OPENJSON([j].[OwnedCollectionRoot], '$') WITH ([OwnedCollectionBranch] nvarchar(max) '$.OwnedCollectionBranch' AS JSON) AS [o] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice example: the 2nd OPENJSON down below gets its WITH clause completely trimmed away, because it's only used for COUNT(*). But its argument referenced [o].[OwnedCollectionBranch]
, which makes it get preserved here on the 1st OPENJSON, as the only one.
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.Query.SqlExpressions; | ||
using ColumnInfo = Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerOpenJsonExpression.ColumnInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can inline and qualify with SqlServerOpenJsonExpression.ColumnInfos if you think that's better..
c683714
to
2992a49
Compare
This extends the new pruner (#32672,
review 2nd commit only) to prune the WITH column list on OPENJSON expressions.Closes #32668