Commit 89f816a
Disallow order by within ordered-set aggregate functions argument lists (apache#20421)
## 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 apache#123` indicates that this PR will close issue apache#123.
-->
- Closes #apache#18281.
## Rationale for this change
This PR fixes incorrect handling of ordered-set aggregate syntax.
<!--
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?
- Updated `datafusion/sql/src/expr/function.rs` to return a planning
error when `ORDER BY` is used inline
- Added test coverage in
`datafusion/sqllogictest/test_files/aggregate.slt` to ensure these
invalid forms now return a syntax/planning error
<!--
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, these changes are tested.
<!--
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?
Yes - this is a public API change.
This query:
```
select quantile_cont(col0, 0.75 order by col0)
from values (1, 3), (2, 2), (3, 1) t(col0, col1);
```
now returns an error: `ORDER BY must be specified using WITHIN GROUP`
<!--
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.
-->
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>1 parent 3f475b1 commit 89f816a
File tree
2 files changed
+85
-16
lines changed- datafusion
- sqllogictest/test_files
- sql/src/expr
2 files changed
+85
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
546 | 576 | | |
547 | 577 | | |
548 | 578 | | |
549 | 579 | | |
550 | 580 | | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
556 | 585 | | |
557 | | - | |
558 | | - | |
559 | 586 | | |
560 | 587 | | |
| 588 | + | |
| 589 | + | |
561 | 590 | | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
568 | 604 | | |
569 | | - | |
570 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
571 | 609 | | |
572 | 610 | | |
573 | 611 | | |
| |||
867 | 905 | | |
868 | 906 | | |
869 | 907 | | |
| 908 | + | |
870 | 909 | | |
871 | 910 | | |
872 | 911 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
128 | 158 | | |
129 | 159 | | |
130 | 160 | | |
| |||
0 commit comments