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


##########
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:
   done



##########
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:
   done



-- 
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