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: Convert unflattened GroupJoin to correlated subquery #28998

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

smitpatel
Copy link
Member

Resolves #19930

{
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
{
if (methodCallExpression.Method.DeclaringType == typeof(Queryable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider returning early it this isn't GroupJoin, to unindent the rest of the method body.

outerKeySelector.Parameters[0],
resultSelector.Parameters[0],
Expression.AndAlso(
Infrastructure.ExpressionExtensions.CreateEqualsExpression(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to check if the outer key is null - do we support that scenario?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Join doesn't match when keys are null even if outer/inner both evaluate to null.

{
var result = Visit(expression);

return _groupJoinConvertingExpressionVisitor.Visit(result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid double visitation here by calling into the GroupJoin conversion logic from VisitMethod (of QueryableMethodNormalizingExpressionVisitor)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot. Flattening of GJ-SM requires visited children and visiting it before flattening will remove GJ.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, was not aware that this same visitor also does GJ flattening. We could do something fancy by havnig a pending GroupJoin bubble up and then either flatten it on SelectMany, or do the new conversion logic if not. But that may be too much.

@@ -132,14 +132,13 @@ public virtual void Throws_when_join()
}

[ConditionalFact]
public virtual void Throws_when_group_join()
public virtual void Does_not_throws_when_group_join()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably remove this with all the other positive tests no?

{
if (methodCallExpression.Method.DeclaringType == typeof(Queryable)
&& methodCallExpression.Method.IsGenericMethod
&& methodCallExpression.Method.GetGenericMethodDefinition()== QueryableMethods.GroupJoin)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&& methodCallExpression.Method.GetGenericMethodDefinition()== QueryableMethods.GroupJoin)
&& methodCallExpression.Method.GetGenericMethodDefinition() == QueryableMethods.GroupJoin)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query: Support GroupJoin when it is final query operator
2 participants