This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch dev-1.0.1 in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit e660dd323c5dfbb1198c429cd368be3b299aa235 Author: dataroaring <98214048+dataroar...@users.noreply.github.com> AuthorDate: Mon Mar 28 12:41:00 2022 +0800 [fix] fix core dump when avg on not null decimal in empty table (#8681) --- .../aggregate_functions/aggregate_function_avg.h | 6 +++-- fe/pom.xml | 2 +- regression-test/suites/empty_table/ddl/empty.sql | 7 +++++ regression-test/suites/empty_table/load.groovy | 31 ++++++++++++++++++++++ .../suites/empty_table/sql/avg_decimal.sql | 1 + 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg.h b/be/src/vec/aggregate_functions/aggregate_function_avg.h index 7b40f95..4aeb7fe 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_avg.h +++ b/be/src/vec/aggregate_functions/aggregate_function_avg.h @@ -40,8 +40,10 @@ struct AggregateFunctionAvgData { if constexpr (std::numeric_limits<ResultT>::is_iec559) return static_cast<ResultT>(sum) / count; /// allow division by zero - if (!count) - throw Exception("AggregateFunctionAvg with zero values", TStatusCode::VEC_LOGIC_ERROR); + if (!count) { + // null is handled in AggregationNode::_get_without_key_result + return static_cast<ResultT>(sum); + } return static_cast<ResultT>(sum) / count; } diff --git a/fe/pom.xml b/fe/pom.xml index 2ac18dd..61aafd7 100644 --- a/fe/pom.xml +++ b/fe/pom.xml @@ -139,7 +139,7 @@ under the License. <java-cup.version>0.11-a-czt02-cdh</java-cup.version> <javassist.version>3.18.2-GA</javassist.version> <javax.servlet-api.version>3.0.1</javax.servlet-api.version> - <je.version>7.3.7</je.version> + <je.version>18.3.12</je.version> <jetty.version>6.1.14</jetty.version> <jflex.version>1.4.3</jflex.version> <jmockit.version>1.49</jmockit.version> diff --git a/regression-test/suites/empty_table/ddl/empty.sql b/regression-test/suites/empty_table/ddl/empty.sql new file mode 100644 index 0000000..c3d423d --- /dev/null +++ b/regression-test/suites/empty_table/ddl/empty.sql @@ -0,0 +1,7 @@ +CREATE TABLE `empty` ( + `c1` INT, + `c2` String, + `c3` Decimal(15, 2) NOT NULL +) +DISTRIBUTED BY HASH(`c1`) BUCKETS 1 +PROPERTIES("replication_num" = "1"); diff --git a/regression-test/suites/empty_table/load.groovy b/regression-test/suites/empty_table/load.groovy new file mode 100644 index 0000000..a8a554e --- /dev/null +++ b/regression-test/suites/empty_table/load.groovy @@ -0,0 +1,31 @@ + +// 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. + +// The cases is copied from https://github.com/trinodb/trino/tree/master +// /testing/trino-product-tests/src/main/resources/sql-tests/testcases +// and modified by Doris. + +def tables=["empty"] + +for (String table in tables) { + sql """ DROP TABLE IF EXISTS $table """ +} + +for (String table in tables) { + sql new File("""${context.file.parent}/ddl/${table}.sql""").text +} diff --git a/regression-test/suites/empty_table/sql/avg_decimal.sql b/regression-test/suites/empty_table/sql/avg_decimal.sql new file mode 100644 index 0000000..d9cdcd2 --- /dev/null +++ b/regression-test/suites/empty_table/sql/avg_decimal.sql @@ -0,0 +1 @@ +SELECT avg(c3) from empty --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org