Fix Rewrite count distinct bitmap and hll order by bug (#3251)
This commit is contained in:
@ -269,8 +269,8 @@ public abstract class QueryStmt extends StatementBase {
|
||||
orderByElementsAfterAnalyzed = Lists.newArrayList();
|
||||
for (int i = 0; i < orderByElements.size(); i++) {
|
||||
// rewrite count distinct
|
||||
Expr rewritten = rewriteCountDistinctForBitmapOrHLL(orderingExprs.get(i), analyzer);
|
||||
OrderByElement orderByElement = new OrderByElement(rewritten, isAscOrder.get(i),
|
||||
orderingExprs.set(i, rewriteCountDistinctForBitmapOrHLL(orderingExprs.get(i), analyzer));
|
||||
OrderByElement orderByElement = new OrderByElement(orderingExprs.get(i), isAscOrder.get(i),
|
||||
nullsFirstParams.get(i));
|
||||
orderByElementsAfterAnalyzed.add(orderByElement);
|
||||
}
|
||||
|
||||
@ -371,15 +371,18 @@ public class QueryPlanTest {
|
||||
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql);
|
||||
Assert.assertTrue(explainString.contains("hll_union_agg"));
|
||||
|
||||
sql = "select count(distinct id2) from test.bitmap_table group by id order by count(distinct id2)";
|
||||
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql);
|
||||
Assert.assertTrue(explainString.contains("bitmap_union_count"));
|
||||
|
||||
sql = "select count(distinct id2) from test.bitmap_table having count(distinct id2) > 0";
|
||||
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql);
|
||||
Assert.assertTrue(explainString.contains("bitmap_union_count"));
|
||||
|
||||
sql = "select count(distinct id2) from test.bitmap_table order by count(distinct id2) > 0";
|
||||
sql = "select count(distinct id2) from test.bitmap_table order by count(distinct id2)";
|
||||
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql);
|
||||
Assert.assertTrue(explainString.contains("bitmap_union_count"));
|
||||
|
||||
|
||||
ConnectContext.get().getSessionVariable().setRewriteCountDistinct(false);
|
||||
sql = "select count(distinct id2) from test.bitmap_table";
|
||||
explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql);
|
||||
|
||||
Reference in New Issue
Block a user