github-actions[bot] commented on code in PR #64774: URL: https://github.com/apache/doris/pull/64774#discussion_r3468891225
########## fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MinMap.java: ########## @@ -0,0 +1,66 @@ +// 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.expressions.functions.agg; + +import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.types.DataType; +import org.apache.doris.nereids.types.DecimalV2Type; +import org.apache.doris.nereids.types.DecimalV3Type; + +import com.google.common.base.Preconditions; + +import java.util.List; + +/** AggregateFunction 'min_map'. */ +public class MinMap extends MapAggregateFunction { + + public MinMap(Expression arg) { + this(false, arg); + } + + public MinMap(boolean distinct, Expression arg) { + super("min_map", distinct, arg); + } + + private MinMap(AggregateFunctionParams functionParams) { + super(functionParams); + } + + @Override + protected DataType argumentValueType(DataType valueType) { + return normalizeValueType(valueType); + } + + @Override + protected DataType returnValueType(DataType valueType) { Review Comment: `min_map` should inherit the same value-type restrictions as `min`, but this path never runs the ordinary `Min.checkLegalityBeforeTypeCoercion()` guard. `returnValueType()` only normalizes DecimalV2 and otherwise preserves MAP/STRUCT values, so a scalar-key expression such as `min_map(CAST(map(1, map(1, 10)) AS map<int,map<int,int>>))` can pass FE analysis even though `min(map<int,int>)` is rejected as an only-metric type. The BE nested aggregate can instantiate min/max state for TYPE_MAP/TYPE_STRUCT, so this creates unsupported complex-value ordering semantics through the new function. Please reject `valueType.isOnlyMetricType() && !valueType.isArrayType()` here and in `MaxMap` with the standard min/max error, or explicitly define and test complex value ordering. -- 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]
