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

Add HAVING support #5889

Merged
merged 1 commit into from
Aug 20, 2020
Merged

Add HAVING support #5889

merged 1 commit into from
Aug 20, 2020

Conversation

Jackie-Jiang
Copy link
Contributor

Description

Add support for SQL HAVING clause

Example of supported query:
SELECT MAX(ArrDelay) - MAX(AirTime) AS Diff, DaysSinceEpoch FROM mytable GROUP BY DaysSinceEpoch HAVING Diff > 500 ORDER BY Diff ASC

for (int rowId = 0; rowId < numRows; rowId++) {
Object[] values = new Object[_numColumns];
for (int colId = 0; colId < _numColumns; colId++) {
switch (columnDataTypes[colId]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Change this to per-value switch based because we have found that this way has better performance (similar change in #4788 for performance improvement)

Copy link
Contributor

@npawar npawar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome. LGTM!

case BYTES:
return _predicateEvaluator.applySV(((ByteArray) value).getBytes());
default:
throw new IllegalStateException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible to run into this branch as the _valueType is set inside the class

query = "SELECT COUNT(*) AS Count, DaysSinceEpoch FROM mytable GROUP BY DaysSinceEpoch HAVING Count > 350";
testSqlQuery(query, Collections.singletonList(query));
query =
"SELECT MAX(ArrDelay) - MAX(AirTime) AS Diff, DaysSinceEpoch FROM mytable GROUP BY DaysSinceEpoch HAVING Diff * 2 > 1000 ORDER BY Diff ASC";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about some queries with AND and OR RowMatchers as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants