mustafasrepo opened a new pull request, #6034: URL: https://github.com/apache/arrow-datafusion/pull/6034
# 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 [#5133](https://github.com/apache/arrow-datafusion/issues/5133). # Rationale for this change A discussed in the [document](https://docs.google.com/document/d/16rm5VR1nGkY6DedMCh1NUmThwf3RduAweaBH9b1h6AY/edit?usp=sharing). If some of the expressions in the `GROUP BY` clause is already ordered. We can generate aggregator results without breaking the pipeline. Consider the query below ```sql SELECT a, b, SUM(c) as summation1 FROM annotated_data GROUP BY a, b ``` If source is ordered by `a, b`. We can calculate group by values in streaming fashion (Corresponds to `Fully Streaming` in the document). When the value of `a, b` columns change, it means that corresponding group will not receive any more values(Otherwise it would contradict with ordering). If the source were ordered by `a`. We can calculate group by values in streaming fashion also ((Corresponds to `Partial Streaming` in the document)). In this case, However, results would be generated when the value of column `a` 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. --> # What changes are included in this PR? This PR enables us to produce non-pipeline breaking results for the conditions `Fully Streaming` and `Partial Streaming`. Please see the [document](https://docs.google.com/document/d/16rm5VR1nGkY6DedMCh1NUmThwf3RduAweaBH9b1h6AY/edit?usp=sharing) for more detailed discussion and what these terms refer. Since the behavior of the executor changes with existing ordering (If result can be calculated in streaming fashion output will have an ordering. Otherwise output will not have an ordering). This functionality requires us to calculate `output_ordering` dynamically. For this reason, this PR accompanies the api change from `fn output_ordering(&self) -> Option<&[PhysicalSortExpr]>` to `fn output_ordering(&self) -> Option<Vec<PhysicalSortExpr>>`. To support dynamic calculation of the output ordering. See the corresponding [PR](https://github.com/synnada-ai/arrow-datafusion/pull/78) for more information. <!-- 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. --> # Are these changes tested? Yes `aggregate_fuzz.rs` file contains random test to check for whether streamed results and existing version produces same result. Also when run on benchmarks I have verified that there is no regression. Benchmark results can be found below | Month | Savings | Savings | Savings | | -------- | ------- | ------- | ------- | | QQuery 1 | 2528.72ms | 2476.56ms | no change | | QQuery 2 | 430.39ms | 428.26ms | no change | | QQuery 3 | 1808.89ms | 1808.69ms | no change | | QQuery 4 | 1475.49ms | 1472.43ms | no change | | QQuery 5 | 1826.64ms | 1829.95ms | no change | | QQuery 6 | 1599.18ms | 1587.20ms | no change | | QQuery 7 | 2123.82ms | 2119.41ms | no change | | QQuery 8 | 1829.00ms | 1820.43ms | no change | | QQuery 9 | 2229.39ms | 2193.94ms | no change | | QQuery 10 | 1827.89ms | 1797.32ms | no change | | QQuery 11 | 416.38ms | 417.49ms | no change | | QQuery 12 | 1655.84ms | 1628.03ms | no change | | QQuery 13 | 673.42ms | 686.45ms | no change | | QQuery 14 | 1550.93ms | 1518.83ms | no change | | QQuery 15 | 3061.58ms | 2999.56ms | no change | | QQuery 16 | 229.33ms | 237.00ms | no change | | QQuery 17 | 5935.75ms | 5963.68ms | no change | | QQuery 18 | 4655.64ms | 4653.72ms | no change | | QQuery 19 | 1829.92ms | 1794.32ms | no change | | QQuery 20 | 2137.18ms | 2129.47ms | no change | | QQuery 21 | 4349.41ms | 4234.84ms | no change | | QQuery 22 | 355.48ms | 352.52ms | no change | <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> # Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> `api change` -- 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]
