From d70776af55cf873fffe0a98b126fc4f18f395d81 Mon Sep 17 00:00:00 2001 From: vhwzIs <33090503+vhwzIs@users.noreply.github.com> Date: Sun, 18 Feb 2024 11:14:33 +0800 Subject: [PATCH] [feature](agg-func) support covar and covar_samp function (#30983) --- .../aggregate_function_covar.cpp | 89 +++++ .../aggregate_function_covar.h | 331 ++++++++++++++++++ .../aggregate_function_simple_factory.cpp | 4 + .../aggregate-functions/covar-samp.md | 48 +++ .../aggregate-functions/covar.md | 48 +++ .../aggregate-functions/covar-samp.md | 49 +++ .../aggregate-functions/covar.md | 49 +++ .../catalog/BuiltinAggregateFunctions.java | 4 + .../org/apache/doris/catalog/FunctionSet.java | 77 ++++ .../expressions/functions/agg/Covar.java | 85 +++++ .../expressions/functions/agg/CovarSamp.java | 85 +++++ .../visitor/AggregateFunctionVisitor.java | 10 + .../agg_function/test_covar.out | 12 + .../agg_function/test_covar_samp.out | 15 + .../agg_function/test_covar.groovy | 82 +++++ .../agg_function/test_covar_samp.groovy | 90 +++++ 16 files changed, 1078 insertions(+) create mode 100644 be/src/vec/aggregate_functions/aggregate_function_covar.cpp create mode 100644 be/src/vec/aggregate_functions/aggregate_function_covar.h create mode 100644 docs/en/docs/sql-manual/sql-functions/aggregate-functions/covar-samp.md create mode 100644 docs/en/docs/sql-manual/sql-functions/aggregate-functions/covar.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/covar-samp.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/covar.md create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Covar.java create mode 100644 fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CovarSamp.java create mode 100644 regression-test/data/nereids_function_p0/agg_function/test_covar.out create mode 100644 regression-test/data/nereids_function_p0/agg_function/test_covar_samp.out create mode 100644 regression-test/suites/nereids_function_p0/agg_function/test_covar.groovy create mode 100644 regression-test/suites/nereids_function_p0/agg_function/test_covar_samp.groovy diff --git a/be/src/vec/aggregate_functions/aggregate_function_covar.cpp b/be/src/vec/aggregate_functions/aggregate_function_covar.cpp new file mode 100644 index 0000000000..aa5bd511d9 --- /dev/null +++ b/be/src/vec/aggregate_functions/aggregate_function_covar.cpp @@ -0,0 +1,89 @@ +// 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. + +#include "vec/aggregate_functions/aggregate_function_covar.h" + +#include + +#include + +#include "common/logging.h" +#include "vec/aggregate_functions/aggregate_function_simple_factory.h" +#include "vec/aggregate_functions/helpers.h" +#include "vec/data_types/data_type.h" +#include "vec/data_types/data_type_nullable.h" + +namespace doris::vectorized { + +template