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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantType.java:
##########
@@ -302,4 +333,62 @@ public int getVariantDocShardCount() {
     public boolean getEnableNestedGroup() {
         return enableNestedGroup;
     }
+
+    public boolean isComputeV2() {
+        return computeV2;
+    }
+
+    /** Whether the type or any nested complex type contains Variant. */
+    public static boolean containsVariant(DataType dataType) {
+        if (dataType instanceof VariantType) {
+            return true;
+        } else if (dataType instanceof ArrayType) {
+            return containsVariant(((ArrayType) dataType).getItemType());
+        } else if (dataType instanceof MapType) {
+            MapType mapType = (MapType) dataType;
+            return containsVariant(mapType.getKeyType()) || 
containsVariant(mapType.getValueType());
+        } else if (dataType instanceof StructType) {
+            return ((StructType) dataType).getFields().stream()
+                    .anyMatch(field -> containsVariant(field.getDataType()));
+        }
+        return false;
+    }
+
+    /** Selects the compute-only Variant representation in a possibly nested 
type. */
+    public static DataType toComputeV2(DataType dataType) {
+        if (dataType instanceof VariantType) {
+            return ((VariantType) dataType).withComputeV2(true);
+        } else if (dataType instanceof ArrayType) {
+            return ArrayType.of(toComputeV2(((ArrayType) 
dataType).getItemType()));
+        } else if (dataType instanceof MapType) {
+            MapType mapType = (MapType) dataType;
+            return MapType.of(toComputeV2(mapType.getKeyType()), 
toComputeV2(mapType.getValueType()));
+        } else if (dataType instanceof StructType) {

Review Comment:
   v2支持计算的 cast struct<variant>, array<variant>



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantType.java:
##########
@@ -225,6 +253,9 @@ public boolean equalsForRecursiveCte(Object o) {
             return false;
         }
         VariantType other = (VariantType) o;
+        if (computeV2 != other.computeV2) {
+            return false;
+        }

Review Comment:
   对



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