morrySnow commented on code in PR #50632: URL: https://github.com/apache/doris/pull/50632#discussion_r2108681520
########## fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4: ########## @@ -1691,7 +1691,7 @@ dataType LEFT_PAREN dataTypes+=dataTypeWithNullable (COMMA dataTypes+=dataTypeWithNullable)* RIGHT_PAREN GT #aggStateDataType | primitiveColType (LEFT_PAREN (INTEGER_VALUE | ASTERISK) - (COMMA INTEGER_VALUE)* RIGHT_PAREN)? #primitiveDataType + (COMMA INTEGER_VALUE)* RIGHT_PAREN)? (ENCODING encoding=STRING_LITERAL)? #primitiveDataType Review Comment: ```suggestion (COMMA INTEGER_VALUE)* RIGHT_PAREN)? (ENCODING encoding=STRING_LITERAL)? #primitiveDataType ``` ########## fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4: ########## @@ -218,6 +218,7 @@ DYNAMIC: 'DYNAMIC'; E:'E'; ELSE: 'ELSE'; ENABLE: 'ENABLE'; +ENCODING: 'ENCODING'; Review Comment: should be non-reserved keyword ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -2840,7 +2841,7 @@ public Expression visitConvertType(DorisParser.ConvertTypeContext ctx) { public DataType visitCastDataType(CastDataTypeContext ctx) { return ParserUtils.withOrigin(ctx, () -> { if (ctx.dataType() != null) { - return ((DataType) typedVisit(ctx.dataType())).conversion(); + return ((TypeAndEncoding) typedVisit(ctx.dataType())).getDataType().conversion(); Review Comment: CstDataType should not allow specific encoding ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -4298,19 +4299,21 @@ private ExplainLevel parseExplainPlanType(PlanTypeContext planTypeContext) { } @Override - public Pair<DataType, Boolean> visitDataTypeWithNullable(DataTypeWithNullableContext ctx) { + public Pair<TypeAndEncoding, Boolean> visitDataTypeWithNullable(DataTypeWithNullableContext ctx) { return ParserUtils.withOrigin(ctx, () -> Pair.of(typedVisit(ctx.dataType()), ctx.NOT() == null)); } @Override - public DataType visitAggStateDataType(AggStateDataTypeContext ctx) { + public TypeAndEncoding visitAggStateDataType(AggStateDataTypeContext ctx) { return ParserUtils.withOrigin(ctx, () -> { - List<Pair<DataType, Boolean>> dataTypeWithNullables = ctx.dataTypes.stream() + List<Pair<TypeAndEncoding, Boolean>> dataTypeWithNullables = ctx.dataTypes.stream() Review Comment: aggState dataType should not allow specific encoding ########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/TypeAndEncoding.java: ########## @@ -0,0 +1,243 @@ +// 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.trees.plans.commands.info; + +import org.apache.doris.catalog.EncodingInfo; +import org.apache.doris.catalog.EncodingTree; +import org.apache.doris.nereids.types.AggStateType; +import org.apache.doris.nereids.types.ArrayType; +import org.apache.doris.nereids.types.BigIntType; +import org.apache.doris.nereids.types.BooleanType; +import org.apache.doris.nereids.types.CharType; +import org.apache.doris.nereids.types.DataType; +import org.apache.doris.nereids.types.DateTimeType; +import org.apache.doris.nereids.types.DateTimeV2Type; +import org.apache.doris.nereids.types.DateType; +import org.apache.doris.nereids.types.DateV2Type; +import org.apache.doris.nereids.types.DecimalV2Type; +import org.apache.doris.nereids.types.DecimalV3Type; +import org.apache.doris.nereids.types.DoubleType; +import org.apache.doris.nereids.types.FloatType; +import org.apache.doris.nereids.types.HllType; +import org.apache.doris.nereids.types.IPv4Type; +import org.apache.doris.nereids.types.IPv6Type; +import org.apache.doris.nereids.types.IntegerType; +import org.apache.doris.nereids.types.JsonType; +import org.apache.doris.nereids.types.LargeIntType; +import org.apache.doris.nereids.types.MapType; +import org.apache.doris.nereids.types.QuantileStateType; +import org.apache.doris.nereids.types.SmallIntType; +import org.apache.doris.nereids.types.StringType; +import org.apache.doris.nereids.types.StructField; +import org.apache.doris.nereids.types.StructType; +import org.apache.doris.nereids.types.TinyIntType; +import org.apache.doris.nereids.types.VarcharType; +import org.apache.doris.nereids.types.VariantType; +import org.apache.doris.nereids.types.coercion.ComplexDataType; +import org.apache.doris.nereids.types.coercion.PrimitiveType; + +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import doris.segment_v2.SegmentV2; +import doris.segment_v2.SegmentV2.EncodingTypePB; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Used to store the type and encoding of a column. + */ +public class TypeAndEncoding { Review Comment: TypeWithEncoding is a better name? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -4525,11 +4551,13 @@ public Command visitCreateUserDefineFunction(CreateUserDefineFunctionContext ctx } else { functionArgTypesInfo = new FunctionArgTypesInfo(new ArrayList<>(), false); } - DataType returnType = typedVisit(ctx.returnType); + TypeAndEncoding returnTypeAndEncoding = typedVisit(ctx.returnType); Review Comment: udf should not allow to specific encoding ########## fe/fe-common/src/main/java/org/apache/doris/catalog/EncodingTree.java: ########## @@ -0,0 +1,58 @@ +// 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.catalog; + +import lombok.Getter; + +import java.util.List; + +public class EncodingTree { + @Getter + private final int encodingNumber; + private final List<EncodingTree> children; Review Comment: why need a tree? if u want to support nested type. i think their item aready has encoding info? ########## fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4: ########## @@ -218,6 +218,7 @@ DYNAMIC: 'DYNAMIC'; E:'E'; ELSE: 'ELSE'; ENABLE: 'ENABLE'; +ENCODING: 'ENCODING'; Review Comment: add to non reserved keywords list in DorisParser.g4 ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/NereidsParser.java: ########## @@ -315,7 +316,8 @@ private static boolean isSimpleIdentifier(String expression) { } public DataType parseDataType(String dataType) { Review Comment: should rename this function. and this function currently only use for parse datatype in table properties for sequence column. so i think it should not to be allowed to specific encoding too -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org