-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[multistage] support HAVING clause #9274
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9274 +/- ##
============================================
+ Coverage 68.75% 69.74% +0.98%
- Complexity 4755 5046 +291
============================================
Files 1859 1873 +14
Lines 99129 99721 +592
Branches 15077 15167 +90
============================================
+ Hits 68161 69546 +1385
+ Misses 26076 25237 -839
- Partials 4892 4938 +46
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -57,6 +57,8 @@ protected Object[][] provideQueries() { | |||
+ " GROUP BY a.col1, a.col2"}, | |||
new Object[]{"SELECT a.col1, AVG(b.col3) FROM a JOIN b ON a.col1 = b.col2 " | |||
+ " WHERE a.col3 >= 0 AND a.col2 = 'a' AND b.col3 < 0 GROUP BY a.col1"}, | |||
new Object[]{"SELECT a.col1, COUNT(*) FROM a WHERE a.col3 >= 0 AND a.col2 = 'a' GROUP BY a.col1" | |||
+ " HAVING COUNT(*) > 10"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding one test each for each supported comparison operator and may be also include a different aggregation function
|
||
|
||
public class FilterOperator extends BaseOperator<TransferableBlock> { | ||
private static final String EXPLAIN_NAME = "HAVING_FILTER"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is giving the impression that it is a hard-coded plan. Currently, the multi-stage engine plan does not support filter in the intermediary stages and wherever possible, filter is pushed down to the leaf stage.
With this PR, we are implementing a FilterOperator that can be used in any of the stages (above leaf), but we are treating it as specifically for executing HAVING filter which may not be the case in future for generic queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. actually this should just be filter operator. since not only HAVING could generate a intermediary filter node. but also non-equality JOIN clauses like SELECT * FROM a JOIN b on a.key = b.key WHERE a.val > b.val
.
it would be a rather inefficient plan to ship all equality over though
Add support for HAVING clause for basic operators (
=
.!=
,<
,<=
,>
,>=
)TODO:
since intermediate stage treats all operands with data type. it is not suitable to convert it back to literal strings like the FilterContext is doing in the pinot server leaf stage. Thus we need to unify