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: Adds support for multi-value Group By query for LINQ #4481

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

leminh98
Copy link
Contributor

@leminh98 leminh98 commented May 13, 2024

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.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

@bartelink
Copy link
Contributor

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>
Copy link
Contributor

@adityasa adityasa May 16, 2024

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
Copy link
Contributor

Choose a reason for hiding this comment

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

ARRAY_LENGTH(root)

Should this be COUNT(root)

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>
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

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

Invalid query?

<SqlQuery><![CDATA[]]></SqlQuery>
<ErrorMessage><![CDATA[Expression with NodeType 'New' is not supported.]]></ErrorMessage>
<SqlQuery><![CDATA[
SELECT r0 AS keyAlias, ARRAY_LENGTH(r0) AS count
Copy link
Contributor

@adityasa adityasa May 16, 2024

Choose a reason for hiding this comment

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

ARRAY_LENGTH(r0)

Should this be COUNT?

Copy link
Contributor

@adityasa adityasa left a 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:
Copy link
Contributor

@adityasa adityasa May 16, 2024

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Enables automation to merge PRs QUERY
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants