This is an automated email from the ASF dual-hosted git repository.
starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b9d7aff92b8 [fix](nereids)agg funs case insensitive (#50444)
b9d7aff92b8 is described below
commit b9d7aff92b818333a41e098c9878fe6c6430ba0a
Author: zhangdong <[email protected]>
AuthorDate: Tue Jul 8 19:43:18 2025 +0800
[fix](nereids)agg funs case insensitive (#50444)
In the table creation process:
The aggregate function name list uses lowercase format
Uppercase function names are validated as invalid
Case-insensitive handling would cause BE errors during INSERT
Solution: Convert function names to lowercase during parsing
---
.../doris/catalog/BuiltinAggregateFunctions.java | 14 +++--
.../apache/doris/nereids/types/AggStateType.java | 4 ++
.../agg_function/test_agg_case_sensitive.out | Bin 0 -> 139 bytes
.../agg_function/test_agg_case_sensitive.groovy | 64 +++++++++++++++++++++
4 files changed, 78 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
index 39557586d2e..2bf9f567bb5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
@@ -88,10 +88,12 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.VarianceSamp;
import org.apache.doris.nereids.trees.expressions.functions.agg.WindowFunnel;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
/**
* Builtin aggregate functions.
@@ -172,9 +174,13 @@ public class BuiltinAggregateFunctions implements
FunctionHelper {
agg(WindowFunnel.class, "window_funnel")
);
- public final Set<String> aggFuncNames = aggregateFunctions.stream()
- .flatMap(fun -> fun.names.stream())
- .collect(ImmutableSet.toImmutableSet());
+ public final Set<String> aggFuncNames = Collections.unmodifiableSet(
+ aggregateFunctions.stream()
+ .flatMap(fun -> fun.names.stream())
+ .collect(Collectors.toCollection(
+ () -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER)
+ ))
+ );
public static final BuiltinAggregateFunctions INSTANCE = new
BuiltinAggregateFunctions();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java
index 258a5be8591..58afdfba27d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java
@@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -76,6 +77,9 @@ public class AggStateType extends DataType {
.copyOf(Objects.requireNonNull(subTypeNullables,
"subTypeNullables should not be null"));
Preconditions.checkState(subTypes.size() == subTypeNullables.size(),
"AggStateType' subTypes.size()!=subTypeNullables.size()");
+ Objects.requireNonNull(functionName, "functionName should not be
null");
+ // be only supports lowercase function names
+ functionName = functionName.toLowerCase(Locale.ROOT);
this.functionName = aliasToName.getOrDefault(functionName,
functionName);
}
diff --git
a/regression-test/data/nereids_function_p0/agg_function/test_agg_case_sensitive.out
b/regression-test/data/nereids_function_p0/agg_function/test_agg_case_sensitive.out
new file mode 100644
index 00000000000..10011d13252
Binary files /dev/null and
b/regression-test/data/nereids_function_p0/agg_function/test_agg_case_sensitive.out
differ
diff --git
a/regression-test/suites/nereids_function_p0/agg_function/test_agg_case_sensitive.groovy
b/regression-test/suites/nereids_function_p0/agg_function/test_agg_case_sensitive.groovy
new file mode 100644
index 00000000000..a861768f330
--- /dev/null
+++
b/regression-test/suites/nereids_function_p0/agg_function/test_agg_case_sensitive.groovy
@@ -0,0 +1,64 @@
+// 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_agg_case_sensitive") {
+ String suiteName = "test_agg_case_sensitive"
+ String tableName = "${suiteName}_table"
+
+ sql """drop table if exists `${tableName}`"""
+
+ sql """ set enable_agg_state=true; """
+ // upper case
+ sql """
+ CREATE TABLE ${tableName} (
+ id INT,
+ k2 AGG_STATE<MAX_BY(int not null,int)> generic
+ )
+ ENGINE=OLAP
+ AGGREGATE KEY (id)
+ DISTRIBUTED BY HASH(id) BUCKETS 10
+ PROPERTIES ("replication_num" = "1");
+ """
+
+ sql """
+ insert into ${tableName} values(1,max_by_state(3,3));
+ """
+
+ qt_sql_upper """select id,max_by_merge(k2) from ${tableName} group by id"""
+
+ sql """drop table if exists `${tableName}`"""
+
+ // lower case
+ sql """
+ CREATE TABLE ${tableName} (
+ id INT,
+ k2 AGG_STATE<max_by(int not null,int)> generic
+ )
+ ENGINE=OLAP
+ AGGREGATE KEY (id)
+ DISTRIBUTED BY HASH(id) BUCKETS 10
+ PROPERTIES ("replication_num" = "1");
+ """
+
+ sql """
+ insert into ${tableName} values(1,max_by_state(3,3));
+ """
+
+ qt_sql_lower """select id,max_by_merge(k2) from ${tableName} group by id"""
+
+ sql """drop table if exists `${tableName}`"""
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]