Skip to content

Commit

Permalink
[BugFix] fix agg skew hint losing having (#53427)
Browse files Browse the repository at this point in the history
Signed-off-by: before-Sunrise <[email protected]>
  • Loading branch information
before-Sunrise authored Dec 2, 2024
1 parent b0329f0 commit 51537af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public List<OptExpression> transform(OptExpression input, OptimizerContext conte
.setSplit()
.setPartitionByColumns(Lists.newArrayList(groupBy))
.setProjection(aggOp.getProjection())
.setPredicate(aggOp.getPredicate())
.build();
fourthAggOp.setDistinctColumnDataSkew(new DataSkewInfo(distinctColRef, 0.5, ++stage));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,19 @@ void testGroupByCountDistinctWithSkewHint() throws Exception {
FeConstants.runningUnitTest = false;
}

@Test
void testGroupByCountDistinctWithSkewHintLossPredicate() throws Exception {
FeConstants.runningUnitTest = true;
String sql =
"select t from(select cast(k1 as int), count(distinct [skew] cast(k2 as int)) as t from db1.tbl1 group by cast(k1 as int)) temp where t > 1";
String s = starRocksAssert.query(sql).explainQuery();
Assert.assertTrue(s, s.contains(" 8:AGGREGATE (merge finalize)\n" +
" | output: sum(7: count)\n" +
" | group by: 5: cast\n" +
" | having: 7: count > 1"));
FeConstants.runningUnitTest = false;
}

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

0 comments on commit 51537af

Please sign in to comment.