Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,11 @@ private List<Expr> getPredicatesBoundedByGroupbysSourceExpr(List<Expr> predicate
Expr sourceExpr = slotDesc.getSourceExprs().get(0);
// if grouping set is given and column is not in all grouping set list
// we cannot push the predicate since the column value can be null
if (stmt.getGroupByClause() == null) {
//group by clause may be null when distinct grouping.
//eg: select distinct c from ( select distinct c from table) t where c > 1;
continue;
}
if (stmt.getGroupByClause().isGroupByExtension()
&& stmt.getGroupByClause().getGroupingExprs().contains(sourceExpr)) {
// if grouping type is CUBE or ROLLUP will definitely produce null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,14 @@ public void testJoinPredicateTransitivityWithSubqueryInWhereClause() throws Exce
Assert.assertTrue(!explainString.contains("PREDICATES"));
}

@Test
public void testDistinctPushDown() throws Exception {
connectContext.setDatabase("default_cluster:test");
String sql = "select distinct k1 from (select distinct k1 from test.pushdown_test) t where k1 > 1";
String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql);
Assert.assertTrue(explainString.contains("PLAN FRAGMENT"));
}

@Test
public void testConstInParitionPrune() throws Exception {
FeConstants.runningUnitTest = true;
Expand Down