csun5285 commented on code in PR #54293:
URL: https://github.com/apache/doris/pull/54293#discussion_r2253329132


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java:
##########
@@ -1041,6 +1052,20 @@ private static void validateScalarType(ScalarType 
scalarType) {
                 }
                 break;
             }
+            case VARIANT: {
+                ArrayList<org.apache.doris.catalog.VariantField> 
predefinedFields =
+                        ((org.apache.doris.catalog.VariantType) 
scalarType).getPredefinedFields();
+                Set<String> fieldPatterns = new HashSet<>();

Review Comment:
   yes



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantField.java:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.types;
+
+import org.apache.doris.nereids.util.Utils;
+import org.apache.doris.thrift.TPatternType;
+
+import java.util.Objects;
+
+/**
+ * A field inside a StructType.
+ */
+public class VariantField {
+    private final String pattern;
+    private final DataType dataType;
+    private final String comment;
+    private final TPatternType patternType;
+
+    public VariantField(String pattern, DataType dataType, String comment) {
+        this(pattern, dataType, comment, TPatternType.MATCH_NAME_GLOB.name());
+    }
+
+    /**
+     * StructField Constructor
+     *  @param pattern of this field
+     *  @param dataType The data type of this field
+     *  @param comment The comment of this field
+     *  @param patternType The patternType of this field
+     */
+    public VariantField(String pattern, DataType dataType, String comment, 
String patternType) {
+        this.pattern = Objects.requireNonNull(pattern, "pattern should not be 
null");
+        this.dataType = Objects.requireNonNull(dataType, "dataType should not 
be null");
+        this.comment = Objects.requireNonNull(comment, "comment should not be 
null");
+        TPatternType type;
+        if (patternType.equalsIgnoreCase("MATCH_NAME")) {

Review Comment:
   done



##########
regression-test/suites/variant_p0/predefine/test_predefine_ddl.groovy:
##########
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_predefine_ddl", "p0") { 
+    def tableName = "test_ddl_table"
+
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """CREATE TABLE ${tableName} (
+        `id` bigint NULL,
+        `var` variant<
+            MATCH_NAME 'ab' : string,
+            MATCH_NAME '*cc' : string,
+            MATCH_NAME_GLOB 'b?b' : string,

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