Skip to content

Commit

Permalink
address pr comments'
Browse files Browse the repository at this point in the history
  • Loading branch information
walterddr committed Aug 27, 2022
1 parent fd6efc7 commit eac41f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ 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"},
new Object[]{"SELECT a.col1, COUNT(*), SUM(a.col3) FROM a WHERE a.col3 >= 0 AND a.col2 = 'a' GROUP BY a.col1 "
+ "HAVING COUNT(*) > 10 AND MAX(a.col3) >= 0 AND MIN(a.col3) < 20 AND SUM(a.col3) <= 10 "
+ "AND AVG(a.col3) = 5"},
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


public class FilterOperator extends BaseOperator<TransferableBlock> {
private static final String EXPLAIN_NAME = "HAVING_FILTER";
private static final String EXPLAIN_NAME = "FILTER";
private final BaseOperator<TransferableBlock> _upstreamOperator;
private final FilterOperand _filterOperand;
private final DataSchema _dataSchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ private Object[][] provideTestSqlAndRowCount() {
+ " (SELECT a.col2 AS joinKey, MAX(a.col3) AS maxVal FROM a GROUP BY a.col2) AS i "
+ " ON b.col1 = i.joinKey", 3},

// Aggregate query with HAVING clause
new Object[]{"SELECT a.col2, COUNT(*) FROM a GROUP BY a.col2 HAVING COUNT(*) < 5", 1},
// Aggregate query with HAVING clause,
// - "foo" and "bar" occurred 6 times each and "alice" occurred 3 times. --> COUNT(*) < 5 matches "alice"
// - col2=="foo"<->col3==1, col2=="bar"<->col3==2, col2="alice"<->col3==42, so SUM(col3) >= 10 matches "bar"
// - last condition doesn't match anything.
new Object[]{"SELECT a.col2, COUNT(*), MAX(a.col3), MIN(a.col3), SUM(a.col3) FROM a GROUP BY a.col2 "
+ "HAVING COUNT(*) < 5 OR (COUNT(*) > 5 AND SUM(a.col3) >= 10) "
+ "OR (MIN(a.col3) != 20 AND SUM(a.col3) = 100)", 2},
};
}
}

0 comments on commit eac41f8

Please sign in to comment.