Skip to content

Commit

Permalink
Fix decode rewrite with order by bug (StarRocks#1227)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangkaisen authored Nov 12, 2021
1 parent 188028e commit 4243609
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public OptExpression visit(OptExpression optExpression, DecodeContext context) {
OptExpression newChildExpr = childExpr.getOp().accept(this, childExpr, context);
if (context.hasEncoded) {
insertDecodeExpr(optExpression, Collections.singletonList(newChildExpr), i, context);
} else {
optExpression.setChild(i, newChildExpr);
}
}
return visitProjectionAfter(optExpression, context);
Expand Down Expand Up @@ -654,7 +656,6 @@ private static OptExpression generateDecodeOExpr(DecodeContext context, List<Opt
return result;
}


private static class CouldApplyDictOptimizeVisitor extends ScalarOperatorVisitor<Boolean, Void> {

public CouldApplyDictOptimizeVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,13 @@ public void testCountDistinctMultiColumns() throws Exception {
Assert.assertTrue(plan.contains(" 5:AGGREGATE (update serialize)\n" +
" | output: count(if(3 IS NULL, NULL, 7))"));
}

@Test
public void testGroupByWithOrderBy() throws Exception {
connectContext.getSessionVariable().setNewPlanerAggStage(2);
String sql = "select max(S_NAME) as b from supplier group by S_ADDRESS order by b";
String plan = getFragmentPlan(sql);
Assert.assertTrue(plan.contains("group by: 10: S_ADDRESS"));
connectContext.getSessionVariable().setNewPlanerAggStage(0);
}
}

0 comments on commit 4243609

Please sign in to comment.