[fix](inbitmap) forbid having clause to include in bitmap. (#15494)

This commit is contained in:
luozenglin
2023-01-04 14:33:18 +08:00
committed by GitHub
parent e0c56bcd20
commit a4af1fbf90
2 changed files with 16 additions and 0 deletions

View File

@ -957,6 +957,13 @@ public class SelectStmt extends QueryStmt {
}
}
private boolean isContainInBitmap(Expr expr) {
List<Expr> inPredicates = Lists.newArrayList();
expr.collect(InPredicate.class, inPredicates);
return inPredicates.stream().anyMatch(e -> e.getChild(1) instanceof Subquery
&& ((Subquery) e.getChild(1)).getStatement().getResultExprs().get(0).getType().isBitmapType());
}
/**
* Analyze aggregation-relevant components of the select block (Group By clause,
* select list, Order By clause),
@ -1017,6 +1024,10 @@ public class SelectStmt extends QueryStmt {
"HAVING clause must not contain analytic expressions: "
+ analyticExpr.toSql());
}
if (isContainInBitmap(havingClauseAfterAnaylzed)) {
throw new AnalysisException(
"HAVING clause dose not support in bitmap syntax: " + havingClauseAfterAnaylzed.toSql());
}
}
if (groupByClause == null && !selectList.isDistinct()

View File

@ -69,4 +69,9 @@ suite("test_bitmap_filter", "query_p0") {
sql "select k1, k2 from ${tbl1} b1 where k1 in (select k2 from ${tbl2} b2 where b1.k2 = b2.k1) order by k1;"
exception "In bitmap does not support correlated subquery"
}
test {
sql "select k1, count(*) from ${tbl1} b1 group by k1 having k1 in (select k2 from ${tbl2} b2) order by k1;"
exception "HAVING clause dose not support in bitmap"
}
}