thinkharderdev opened a new pull request, #2716:
URL: https://github.com/apache/arrow-datafusion/pull/2716

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   Closes #1327
   
   TODO
   
   - [ ] Implement CUBE expansion
   - [ ] Implement ROLLUP expansion
   - [ ] Add SQL tests for CUBE/ROLLUP queries
   - [ ] Pass partitioning expressions directly to `AggregateExec`
   
   Note that currently the sql parser doesn't seem to handle `GROUP BY GROUPING 
SETS ...` so we need to address that to test that explicitly. 
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   This PR adds support for GROUPING SETS (and special cases CUBE/ROLLUP) in 
the physical planner and execution plan.
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   There are three primary changes:
   
   1. `AggregateExec` now takes a `Vec<Vec<(Arc<dyn PhysicalExpr>,String)>>` to 
represent grouping sets. A normal `GROUP BY` is just a special case. We expect 
the grouping sets to be "aligned". For example, for a SQL clause like `GROUP BY 
GROUPING SETS ((a),(b),(a,b))`, `AggregateExec` assumes that the planner will 
expand that to the grouping set `((a,NULL),(NULL,b),(a,b))`. We can't handle 
this in the execution plan because we don't have `ParialEq` for `PhysicalExpr`.
   2. In `DefaultPhysicalPlanner` handle expanding and aligning grouping sets. 
This includes expanding CUBE/ROLLUP expressions and merging and aligning 
GROUPING SET expressions. 
   3. Handle grouping sets correctly in optimizers. 
   
   Also we include serialization for grouping set expression in 
`datafusion-proto`  
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   SQL statements with CUBE/ROLLUP should now be supported. GROUPING SETS 
should also be supported but it seems like the sql parser is not handling them 
correctly. 
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   
   I don't think so. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to