From 9e696d72f1b28a54784342be8597d54de33361cf Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:00:39 +0800 Subject: [PATCH] [fix](nereids)check functionBuilders is not null before using it (#38535) ## Proposed changes pick from master https://github.com/apache/doris/pull/38457 --- .../doris/catalog/FunctionRegistry.java | 8 ++-- .../data/correctness_p0/test_orderby_mod.out | 7 ++++ .../correctness_p0/test_orderby_mod.groovy | 41 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 regression-test/data/correctness_p0/test_orderby_mod.out create mode 100644 regression-test/suites/correctness_p0/test_orderby_mod.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java index 020d302232..0e049b4b90 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionRegistry.java @@ -90,9 +90,11 @@ public class FunctionRegistry { Class aggClass = org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction.class; if (StringUtils.isEmpty(dbName)) { List functionBuilders = name2BuiltinBuilders.get(name); - for (FunctionBuilder functionBuilder : functionBuilders) { - if (aggClass.isAssignableFrom(functionBuilder.functionClass())) { - return true; + if (functionBuilders != null) { + for (FunctionBuilder functionBuilder : functionBuilders) { + if (aggClass.isAssignableFrom(functionBuilder.functionClass())) { + return true; + } } } } diff --git a/regression-test/data/correctness_p0/test_orderby_mod.out b/regression-test/data/correctness_p0/test_orderby_mod.out new file mode 100644 index 0000000000..040aa0cedd --- /dev/null +++ b/regression-test/data/correctness_p0/test_orderby_mod.out @@ -0,0 +1,7 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_mod -- +10 3.3 3 + +-- !select_op -- +10 3.3 3 + diff --git a/regression-test/suites/correctness_p0/test_orderby_mod.groovy b/regression-test/suites/correctness_p0/test_orderby_mod.groovy new file mode 100644 index 0000000000..08112f1a36 --- /dev/null +++ b/regression-test/suites/correctness_p0/test_orderby_mod.groovy @@ -0,0 +1,41 @@ + +// 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_order_by_mod") { + sql """set enable_nereids_planner=true""" + sql """ + drop table if exists order_by_mod_t; + """ + + sql """ + create table order_by_mod_t(a int, b float, c int) + duplicate key(a) + distributed by hash(a) buckets 1 + properties ("replication_num" = "1"); + """ + + sql """ + insert into order_by_mod_t values (10, 3.3, 3), (20, 3.3, 3);; + """ + qt_select_mod """ + select * from order_by_mod_t order by mod(a,c) limit 1;; + """ + qt_select_op """ + select * from order_by_mod_t order by a % c limit 1; + """ +}