xiaokang commented on code in PR #17344: URL: https://github.com/apache/doris/pull/17344#discussion_r1124355443
########## fe/fe-common/src/main/java/org/apache/doris/catalog/MapType.java: ########## @@ -121,6 +122,33 @@ public boolean matchesType(Type t) { && (valueType.matchesType(((MapType) t).valueType)); } + @Override + public boolean hasTemplateType() { + return keyType.hasTemplateType() || valueType.hasTemplateType(); + } + + @Override + public Type specializeTemplateType(Type specificType, Map<String, Type> specializedTypeMap, + boolean useSpecializedType) throws TypeException { + if (!(specificType instanceof MapType)) { + throw new TypeException(specificType + " is not MapType"); + } + + MapType specificMapType = (MapType) specificType; + Type newKeyType = keyType; + if (keyType.hasTemplateType()) { + newKeyType = keyType.specializeTemplateType( + specificMapType.keyType, specializedTypeMap, useSpecializedType); + } + Type newValueType = valueType; + if (valueType.hasTemplateType()) { + newValueType = valueType.specializeTemplateType( + specificMapType.valueType, specializedTypeMap, useSpecializedType); + } + + return new MapType(newKeyType, newValueType); Review Comment: yes. MAP<K, INT> + MAP<STRING, BIGINT> => MAP<STRING, BIGINT> is wrong if canCastTo not checked. ########## fe/fe-common/src/main/java/org/apache/doris/catalog/TemplateType.java: ########## @@ -0,0 +1,131 @@ +// 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 org.apache.doris.thrift.TColumnType; +import org.apache.doris.thrift.TTypeDesc; + +import com.google.common.base.Strings; +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +/** + * Describes a TemplateType type. + */ +public class TemplateType extends Type { + + @SerializedName(value = "name") + private final String name; + + public TemplateType(String name) { + this.name = name; + } + + @Override + public PrimitiveType getPrimitiveType() { + return PrimitiveType.TEMPLATE; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof TemplateType)) { + return false; + } + TemplateType o = (TemplateType) other; + return o.name.equals(name); + } + + @Override + public boolean matchesType(Type t) { + // not matches any type + return false; + } + + @Override + public boolean hasTemplateType() { + return true; + } + + @Override + public Type specializeTemplateType(Type specificType, Map<String, Type> specializedTypeMap, + boolean useSpecializedType) throws TypeException { + if (specificType.hasTemplateType()) { Review Comment: ok -- 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