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: Add support for SQL GROUP BY #16381

Merged
merged 2 commits into from
Jul 2, 2019
Merged

Conversation

smitpatel
Copy link
Member

@smitpatel smitpatel commented Jul 1, 2019

This allows us to use those methods to translate aggregates after GroupBy

Resolves #15718
Query: Translate to SQL GROUP BY when aggregate operator is applied after GroupBy

Resolves #12826
Resolves #6658
Part of #15711
Resolves #15853
Resolves #12799
Resolves #12476
Resolves #11976

@smitpatel smitpatel requested a review from dougbu as a code owner July 2, 2019 02:01
@smitpatel smitpatel changed the base branch from master to release/3.0-preview7 July 2, 2019 02:01
@smitpatel
Copy link
Member Author

Re-targeting to preview7. This is pre-requisite for SQL GroupBy work.

@smitpatel smitpatel requested review from ajcvickers and removed request for dougbu July 2, 2019 02:03
This allows us to use those methods to translate aggregates after GroupBy

Resolves #15718
…fter GroupBy

Resolves #12826
Resolves #6658
Part of #15711
Resolves #15853
Resolves #12799
Resolves #12476
Resolves #11976

There are way too many existing issues are resolved by this PR. I haven't added regression test or verified each of them so I have put Verify-Fixed label on them for now.
@smitpatel smitpatel changed the title Query: Move processing of aggregate functions inside SqlTranslator Query: Add support for SQL GROUP BY Jul 2, 2019
@@ -5197,7 +5197,7 @@ public virtual Task Select_orderBy_take_count(bool isAsync)
cs => cs.OrderBy(c => c.Country).Take(7));
}

[ConditionalTheory(Skip = "Issue#15718")]
[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Select_take_long_count(bool isAsync)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any coverage asserting the SQL for LongCount outside of SQL Server (where the default behavior is overridden). Can we assert the SQL in a SQLite test for coverage?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

@@ -336,29 +474,25 @@ protected override Expression VisitParameter(ParameterExpression parameterExpres

protected override Expression VisitExtension(Expression extensionExpression)
{
if (extensionExpression is EntityShaperExpression)
switch (extensionExpression)
Copy link
Member

Choose a reason for hiding this comment

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

Nobody likes switch expression in this project :(

Copy link
Member Author

Choose a reason for hiding this comment

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

I converted to switch, no?
It wasn't switch earlier because it started with just 1 if and expanded later.

Copy link
Member

Choose a reason for hiding this comment

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

I meant the new C# 8 expression, not switch statement - submitted #16421 which I hope we like.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it reduces readability especially when doing function call rather than just returning some value.

Copy link
Contributor

Choose a reason for hiding this comment

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

lol, I'm seeing a lot of people in the community who don't like the new switch expression. It'll be interesting to see where it does and doesn't get used. It feels a lot like LINQ comprehension syntax where it improves readability for some things, but makes it worse for others.

{
Predicate = expression;
if (HavingExpression == null)
Copy link
Member

Choose a reason for hiding this comment

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

nit: conditional operator

expression,
typeof(bool),
expression.TypeMapping);
if (Predicate == null)
Copy link
Member

Choose a reason for hiding this comment

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

nit: conditional operator

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.

4 participants