[feature](Nereids): make count() avaliable for all data type (#26180)

make count() avaliable for all data type
This commit is contained in:
谢健
2023-11-02 17:20:24 +08:00
committed by GitHub
parent 6828250207
commit c46fa339d0
7 changed files with 450 additions and 24 deletions

View File

@ -18,7 +18,6 @@
package org.apache.doris.nereids.trees.expressions.functions.agg;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.catalog.Type;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
@ -82,11 +81,9 @@ public class Count extends AggregateFunction
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().isObjectType()) {
throw new AnalysisException(Type.OnlyObjectTypeErrorMsg);
}
if (distinct && argument.getDataType().isComplexType()) {
throw new AnalysisException("COUNT DISTINCT could not process complex type " + this.toSql());
if (distinct && (argument.getDataType().isComplexType()
|| argument.getDataType().isObjectType() || argument.getDataType().isJsonType())) {
throw new AnalysisException("COUNT DISTINCT could not process type " + this.toSql());
}
}
}