csun5285 commented on code in PR #54293:
URL: https://github.com/apache/doris/pull/54293#discussion_r2253324702
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantType.java:
##########
@@ -18,26 +18,68 @@
package org.apache.doris.nereids.types;
import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.annotation.Developing;
import org.apache.doris.nereids.types.coercion.PrimitiveType;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* Variant type in Nereids.
* Why Variant is not complex type? Since it's nested structure is not
pre-defined, then using
* primitive type will be easy to handle meta info in FE.
+ * Also, could predefine some fields of nested columns.
+ * Example: VARIANT <`a.b`:INT, a.c:DATETIMEV2>
+ *
*/
-@Developing
public class VariantType extends PrimitiveType {
- public static final VariantType INSTANCE = new VariantType();
+ public static final VariantType INSTANCE = new VariantType(0);
public static final int WIDTH = 24;
+ private int variantMaxSubcolumnsCount = 0;
+
+ private boolean enableTypedPathsToSparse = false;
Review Comment:
done
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantType.java:
##########
@@ -18,26 +18,68 @@
package org.apache.doris.nereids.types;
import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.annotation.Developing;
import org.apache.doris.nereids.types.coercion.PrimitiveType;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* Variant type in Nereids.
* Why Variant is not complex type? Since it's nested structure is not
pre-defined, then using
* primitive type will be easy to handle meta info in FE.
+ * Also, could predefine some fields of nested columns.
+ * Example: VARIANT <`a.b`:INT, a.c:DATETIMEV2>
+ *
*/
-@Developing
public class VariantType extends PrimitiveType {
- public static final VariantType INSTANCE = new VariantType();
+ public static final VariantType INSTANCE = new VariantType(0);
public static final int WIDTH = 24;
+ private int variantMaxSubcolumnsCount = 0;
+
+ private boolean enableTypedPathsToSparse = false;
+
+ private final List<VariantField> predefinedFields;
+
+ // No predefined fields
+ public VariantType(int variantMaxSubcolumnsCount) {
+ this.variantMaxSubcolumnsCount = variantMaxSubcolumnsCount;
+ predefinedFields = Lists.newArrayList();
+ }
+
+ /**
+ * Contains predefined fields like struct
+ */
+ public VariantType(List<VariantField> fields) {
+ this.predefinedFields =
ImmutableList.copyOf(Objects.requireNonNull(fields, "fields should not be
null"));
+ }
+
+ public VariantType(List<VariantField> fields, int
variantMaxSubcolumnsCount, boolean enableTypedPathsToSparse) {
+ this.predefinedFields =
ImmutableList.copyOf(Objects.requireNonNull(fields, "fields should not be
null"));
+ this.variantMaxSubcolumnsCount = variantMaxSubcolumnsCount;
+ this.enableTypedPathsToSparse = enableTypedPathsToSparse;
+ }
+
+ @Override
+ public DataType conversion() {
+ return new
VariantType(predefinedFields.stream().map(VariantField::conversion)
+ .collect(Collectors.toList()),
variantMaxSubcolumnsCount,
+
enableTypedPathsToSparse);
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]