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: invalid sql generated for query with groupby aggregate pushdown projecting constant on top #12569

Closed
maumar opened this issue Jul 5, 2018 · 1 comment
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 5, 2018

query using Northwind model:

                var query = ctx.Orders.GroupBy(e => e.CustomerID)
                        .Where(g => g.Count() > 10)
                        .Select(g => g.Key)
                        .OrderBy(t => t)
                        .Take(20)
                        .Skip(4).Select(e => 1);

Query plan:

(QueryContext queryContext) => IEnumerable<int> _InterceptExceptions(
|__ source: IEnumerable<int> _ShapedQuery(
|   |__ queryContext: queryContext, 
|   |__ shaperCommandContext: SelectExpression: 
|   |       SELECT [t].*
|   |       FROM (
|   |           SELECT TOP(@__p_0) [e].*, [e].[CustomerID] AS [Key]
|   |           FROM [Orders] AS [e]
|   |           GROUP BY [e].[CustomerID]
|   |           HAVING COUNT(*) > 10
|   |           ORDER BY [c]
|   |       ) AS [t]
|   |       ORDER BY [t].[Key]
|   |       OFFSET @__p_1 ROWS, 
|   |__ shaper: (QueryContext queryContext | ValueBuffer g) => 1), 
|__ contextType: TestModels.Northwind.NorthwindRelationalContext, 
|__ logger: DiagnosticsLogger<Query>, 
|__ queryContext: Unhandled parameter: queryContext)

exception:

Column 'Orders.OrderID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Invalid column name 'c'.
@smitpatel
Copy link
Contributor

Test: GroupBy_aggregate_Pushdown_followed_by_projecting_constant
Enabled in #16381

@smitpatel smitpatel modified the milestones: Backlog, 3.0.0 Dec 10, 2019
@smitpatel smitpatel added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed add-regression-test punted-for-3.0 try-on-latest labels Dec 10, 2019
@smitpatel smitpatel self-assigned this Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants