Skip to content

Commit

Permalink
[fix](Nereids) count should not accept complex and json type (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
morrySnow authored Oct 16, 2023
1 parent dfc7d04 commit 4c57c31
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 178 deletions.
5 changes: 5 additions & 0 deletions fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ public boolean isOnlyMetricType() {
return isObjectStored() || isComplexType() || isJsonbType() || isVariantType();
}

public static final String OnlyObjectTypeErrorMsg =
"Doris hll, bitmap column must use with specific function, and don't"
+ " support filter, group by or order by. please run 'help hll' or 'help bitmap'"
+ " in your mysql client.";

public static final String OnlyMetricTypeErrorMsg =
"Doris hll, bitmap, array, map, struct, jsonb, variant column must use with specific function, and don't"
+ " support filter, group by or order by. please run 'help hll' or 'help bitmap' or 'help array'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Count(boolean distinct, Expression arg0, Expression... varArgs) {

public boolean isCountStar() {
return isStar
|| children.size() == 0
|| children.isEmpty()
|| (children.size() == 1 && child(0) instanceof Literal);
}

Expand All @@ -82,8 +82,11 @@ public void checkLegalityBeforeTypeCoercion() {
public void checkLegalityAfterRewrite() {
// after rewrite, count(distinct bitmap_column) should be rewritten to bitmap_union_count(bitmap_column)
for (Expression argument : getArguments()) {
if (argument.getDataType().isOnlyMetricType()) {
throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
if (argument.getDataType().isObjectType()) {
throw new AnalysisException(Type.OnlyObjectTypeErrorMsg);
}
if (distinct && argument.getDataType().isComplexType()) {
throw new AnalysisException("COUNT DISTINCT could not process complex type " + this.toSql());
}
}
}
Expand Down
Loading

0 comments on commit 4c57c31

Please sign in to comment.