morrySnow commented on code in PR #63479:
URL: https://github.com/apache/doris/pull/63479#discussion_r3347264993


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java:
##########
@@ -92,13 +92,29 @@ 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 (distinct && (argument.getDataType().isComplexType()
-                    || argument.getDataType().isObjectType() || 
argument.getDataType().isJsonType())) {
-                throw new AnalysisException("COUNT DISTINCT could not process 
type " + this.toSql());
+            if (distinct) {
+                checkDistinctArgument(argument, this.toSql());
             }
         }
     }
 
+    static void checkDistinctArgument(Expression argument, String functionSql) 
{
+        checkVariantArgument(argument, functionSql);
+        DataType argumentType = argument.getDataType();
+        if (argumentType.isComplexType() || argumentType.isObjectType() || 
argumentType.isJsonType()) {
+            throw new AnalysisException("COUNT DISTINCT could not process type 
" + functionSql);
+        }
+    }
+
+    static void checkVariantArgument(Expression argument, String functionSql) {
+        DataType argumentType = argument.getDataType();
+        if (argumentType.isVariantType()) {
+            throw new AnalysisException("COUNT DISTINCT does not support 
VARIANT argument in " + functionSql
+                    + ". Cast the VARIANT expression to STRING or another 
supported scalar type before using "
+                    + "COUNT DISTINCT.");

Review Comment:
   为什么要和其他类型的报错信息不一致呢?如果variant修改了这个报错信息,json也可以用啊。所以不要给variant单独搞一个分支



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Count.java:
##########
@@ -92,13 +92,29 @@ 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 (distinct && (argument.getDataType().isComplexType()
-                    || argument.getDataType().isObjectType() || 
argument.getDataType().isJsonType())) {
-                throw new AnalysisException("COUNT DISTINCT could not process 
type " + this.toSql());
+            if (distinct) {
+                checkDistinctArgument(argument, this.toSql());

Review Comment:
   把参数改成 Expression,只在抛异常的时候,再调用 toSql



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to