-
Notifications
You must be signed in to change notification settings - Fork 477
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: Adds support for multi-value Group By query for LINQ #4481
base: master
Are you sure you want to change the base?
Conversation
Semi-related issues in case they are easy to address in the same block of work:
|
JOIN value IN root)) AS v2 | ||
GROUP BY root["id"] | ||
]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":129,"end":134},"code":"SC1001","message":"Syntax error, incorrect syntax near 'value'."}]},0x800A0B00]]></ErrorMessage> |
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 seems to indicate invalid query is being generated?
<SqlQuery><![CDATA[]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Expression with NodeType 'New' is not supported.]]></ErrorMessage> | ||
<SqlQuery><![CDATA[ | ||
SELECT root["FamilyId"] AS familyId, ARRAY_LENGTH(root) AS familyIdCount |
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.
JOIN v2 IN root)) AS v3 | ||
GROUP BY root["id"] | ||
]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":7,"end":9},"code":"SC2102","message":"Property reference 'v1' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."},{"severity":"Error","location":{"start":21,"end":23},"code":"SC2102","message":"Property reference 'v3' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."}]},0x800A0B00]]></ErrorMessage> |
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.
Same as before. Seems like invalid query is being generated?
ORDER BY f["FamilyId"] ASC)) AS v1 | ||
GROUP BY root["id"] | ||
]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":93,"end":98},"code":"SC1001","message":"Syntax error, incorrect syntax near 'value'."}]},0x800A0B00]]></ErrorMessage> |
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.
Invalid query?
SELECT VALUE root["id"] | ||
FROM root) AS r0 | ||
GROUP BY r0 | ||
]]></SqlQuery> | ||
</Output> | ||
</Result> |
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.
the data set is randomly generated. I don't think that would work with the baseline. Unless we fix the seed
<SqlQuery><![CDATA[]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Expression with NodeType 'New' is not supported.]]></ErrorMessage> | ||
<SqlQuery><![CDATA[ | ||
SELECT r0 AS keyAlias, ARRAY_LENGTH(r0) AS count |
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.
<SqlQuery><![CDATA[]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Expression with NodeType 'New' is not supported.]]></ErrorMessage> | ||
<SqlQuery><![CDATA[ | ||
SELECT root["id"] AS Key, root["id"] AS key |
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.
FROM root | ||
GROUP BY root["id"] | ||
ORDER BY root["Int"] ASC]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":99,"end":110},"code":"SC2103","message":"Property reference 'root[\"Int\"]' is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause."},{"severity":"Error","location":{"start":44,"end":48},"code":"SC2102","message":"Property reference 'root' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."}]},0x800A0B00]]></ErrorMessage> |
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.
Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":99,"end":110},"code":"SC2103","message":"Property reference 'root["Int"]' is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause."},{"severity":"Error","location":{"start":44,"end":48},"code":"SC2102","message":"Property reference 'root' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."}]},0x800A0B00
Can you resolve these errors? #Resolved
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 expected errors since we don't support order by and group by togerther
FROM root | ||
GROUP BY root["id"] | ||
ORDER BY root["id"] DESC]]></SqlQuery> | ||
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":44,"end":48},"code":"SC2102","message":"Property reference 'root' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."}]},0x800A0B00]]></ErrorMessage> |
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.
Is there a way for customers to resolve this error? #Resolved
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.
none other than not combining groupby and order by since we dont support it
@@ -1046,6 +1046,11 @@ public void TestGroupByMultiValueTranslation() | |||
stringField = "abc" | |||
}))); | |||
|
|||
for(int i = 0; i < inputs.Count; i++) | |||
{ | |||
inputs[i].ignoreOrderingForAnonymousTypeObject = true; |
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.
We should avoid this for ORDER BY queries. #Resolved
return queryResults.SequenceEqual(dataResults); | ||
} | ||
|
||
return queryResults.OrderBy(x => x).ToList().SequenceEqual(dataResults.OrderBy(x => x).ToList()); |
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.
Ternary would be useful:
return ignoreOrdering?
. . . :
. . .; #Resolved
@@ -1046,6 +1046,11 @@ public void TestGroupByMultiValueTranslation() | |||
stringField = "abc" | |||
}))); | |||
|
|||
for(int i = 0; i < inputs.Count; i++) | |||
{ | |||
inputs[i].ignoreOrderingForAnonymousTypeObject = true; |
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.
@@ -646,17 +651,21 @@ public class LinqTestInput : BaselineTestInput | |||
// - unordered query since the results are not deterministics for LinQ results and actual query results | |||
// - scenarios not supported in LINQ, e.g. sequence doesn't contain element. | |||
internal bool skipVerification; | |||
|
|||
internal bool ignoreOrderingForAnonymousTypeObject; |
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.
readonly? #Resolved
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.
🕐
throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.ExpressionTypeIsNotSupported, ExpressionType.New)); | ||
break; | ||
} | ||
case ExpressionType.New: |
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 am not able to make the 1:1 connection between new expression and multi-value group by.
IOW, it's not clear why every new expression here is a multi-value GROUP BY and vice-versa. #Resolved
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.
it's group by syntax as defined by LINQ
https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.groupby?view=net-8.0
Pull Request Template
Description
This PR adds the ability to translate LINQ query to SQL query with multiple items in the SQL select clause. This is achieved through the value clause using NewExpression
Type of change
Please delete options that are not relevant.
Closing issues
To automatically close an issue: closes #IssueNumber