This is an automated email from the ASF dual-hosted git repository.

zclll 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 e984a38a7bd [Enhancement](doris-future) Support REGR_ARGX, REGR_ARGY, 
REGR_COUNT and REGR_R2 aggregate functions (#61352)
e984a38a7bd is described below

commit e984a38a7bd3be436f6e8021b2045be53b2d0c1e
Author: Jover <[email protected]>
AuthorDate: Tue Apr 14 11:29:31 2026 +0800

    [Enhancement](doris-future) Support REGR_ARGX, REGR_ARGY, REGR_COUNT and 
REGR_R2 aggregate functions (#61352)
    
    Issue Number: #38974, #38976
    
    Related PR: #55940
    
    Problem Summary:
    
    This PR completes the remaining statistical regression aggregate
    functions (`REGR_*`) by adding support for `REGR_AVGX`, `REGR_AVGY`,
    `REGR_COUNT`, and `REGR_R2`, based on the unified Regr aggregate
    function
      approach introduced in #55940.
---
 be/src/exprs/aggregate/aggregate_function_regr.cpp |  93 ++++
 be/src/exprs/aggregate/aggregate_function_regr.h   | 533 +++++++++++++++++++++
 .../aggregate/aggregate_function_regr_union.cpp    |  66 ---
 .../aggregate/aggregate_function_regr_union.h      | 389 ---------------
 .../aggregate_function_simple_factory.cpp          |   4 +-
 .../doris/catalog/BuiltinAggregateFunctions.java   |   8 +
 .../functions/agg/{RegrSxy.java => RegrAvgx.java}  |  36 +-
 .../functions/agg/{RegrSxy.java => RegrAvgy.java}  |  36 +-
 .../functions/agg/{RegrSxy.java => RegrCount.java} |  44 +-
 .../expressions/functions/agg/RegrIntercept.java   |  15 -
 .../functions/agg/{RegrSxy.java => RegrR2.java}    |  36 +-
 .../trees/expressions/functions/agg/RegrSlope.java |  15 -
 .../trees/expressions/functions/agg/RegrSxx.java   |  18 -
 .../trees/expressions/functions/agg/RegrSxy.java   |  18 -
 .../trees/expressions/functions/agg/RegrSyy.java   |  18 -
 .../visitor/AggregateFunctionVisitor.java          |  20 +
 .../data/query_p0/aggregate/test_regr_avgx.out     |  63 +++
 .../data/query_p0/aggregate/test_regr_avgy.out     |  63 +++
 .../data/query_p0/aggregate/test_regr_count.out    |  63 +++
 .../query_p0/aggregate/test_regr_intercept.out     |  25 +-
 .../data/query_p0/aggregate/test_regr_r2.out       |  65 +++
 .../data/query_p0/aggregate/test_regr_slope.out    |  25 +-
 .../aggregate}/test_regr_sxx.out                   |  15 +
 .../aggregate}/test_regr_sxy.out                   |  15 +
 .../aggregate}/test_regr_syy.out                   |  15 +
 .../query_p0/aggregate/test_regr_avgx.groovy       | 174 +++++++
 .../query_p0/aggregate/test_regr_avgy.groovy       | 174 +++++++
 .../query_p0/aggregate/test_regr_count.groovy      | 174 +++++++
 .../query_p0/aggregate/test_regr_intercept.groovy  |  32 +-
 .../suites/query_p0/aggregate/test_regr_r2.groovy  | 172 +++++++
 .../query_p0/aggregate/test_regr_slope.groovy      |  32 +-
 .../aggregate}/test_regr_sxx.groovy                |  23 +-
 .../aggregate}/test_regr_sxy.groovy                |  25 +-
 .../aggregate}/test_regr_syy.groovy                |  23 +-
 34 files changed, 1810 insertions(+), 717 deletions(-)

diff --git a/be/src/exprs/aggregate/aggregate_function_regr.cpp 
b/be/src/exprs/aggregate/aggregate_function_regr.cpp
new file mode 100644
index 00000000000..1cbbc1a69a5
--- /dev/null
+++ b/be/src/exprs/aggregate/aggregate_function_regr.cpp
@@ -0,0 +1,93 @@
+// 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 "exprs/aggregate/aggregate_function_regr.h"
+
+#include "core/data_type/data_type.h"
+#include "core/data_type/define_primitive_type.h"
+#include "exprs/aggregate/aggregate_function.h"
+#include "exprs/aggregate/aggregate_function_simple_factory.h"
+#include "exprs/aggregate/factory_helpers.h"
+#include "exprs/aggregate/helpers.h"
+
+namespace doris {
+
+template <RegrFunctionKind kind>
+AggregateFunctionPtr create_aggregate_function_regr(const std::string& name,
+                                                    const DataTypes& 
argument_types,
+                                                    const DataTypePtr& 
result_type,
+                                                    const bool 
result_is_nullable,
+                                                    const 
AggregateFunctionAttr& attr) {
+    assert_arity_range(name, argument_types, 2, 2);
+    DCHECK(argument_types[0]->get_primitive_type() == TYPE_DOUBLE);
+    DCHECK(argument_types[1]->get_primitive_type() == TYPE_DOUBLE);
+    if constexpr (kind == RegrFunctionKind::regr_count) {
+        DCHECK(result_type->get_primitive_type() == TYPE_BIGINT);
+        DCHECK(!result_is_nullable);
+    } else {
+        DCHECK(result_type->get_primitive_type() == TYPE_DOUBLE);
+        DCHECK(result_is_nullable);
+    }
+
+    bool y_nullable_input = argument_types[0]->is_nullable();
+    bool x_nullable_input = argument_types[1]->is_nullable();
+    if (y_nullable_input) {
+        if (x_nullable_input) {
+            return creator_without_type::create_ignore_nullable<
+                    AggregateFunctionRegr<TYPE_DOUBLE, kind, true, 
true>>(argument_types,
+                                                                          
result_is_nullable, attr);
+        } else {
+            return creator_without_type::create_ignore_nullable<
+                    AggregateFunctionRegr<TYPE_DOUBLE, kind, true, false>>(
+                    argument_types, result_is_nullable, attr);
+        }
+    } else {
+        if (x_nullable_input) {
+            return creator_without_type::create_ignore_nullable<
+                    AggregateFunctionRegr<TYPE_DOUBLE, kind, false, true>>(
+                    argument_types, result_is_nullable, attr);
+        } else {
+            return creator_without_type::create_ignore_nullable<
+                    AggregateFunctionRegr<TYPE_DOUBLE, kind, false, false>>(
+                    argument_types, result_is_nullable, attr);
+        }
+    }
+}
+
+void register_aggregate_function_regr(AggregateFunctionSimpleFactory& factory) 
{
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_avgx>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_avgx>);
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_avgy>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_avgy>);
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_count>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_count>);
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_slope>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_slope>);
+    factory.register_function_both(
+            RegrTraits<RegrFunctionKind::regr_intercept>::name,
+            create_aggregate_function_regr<RegrFunctionKind::regr_intercept>);
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_sxx>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_sxx>);
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_syy>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_syy>);
+    
factory.register_function_both(RegrTraits<RegrFunctionKind::regr_sxy>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_sxy>);
+    factory.register_function_both(RegrTraits<RegrFunctionKind::regr_r2>::name,
+                                   
create_aggregate_function_regr<RegrFunctionKind::regr_r2>);
+}
+
+} // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_regr.h 
b/be/src/exprs/aggregate/aggregate_function_regr.h
new file mode 100644
index 00000000000..7eb3ed90bed
--- /dev/null
+++ b/be/src/exprs/aggregate/aggregate_function_regr.h
@@ -0,0 +1,533 @@
+// 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.
+
+#pragma once
+
+#include <array>
+#include <cmath>
+#include <cstdint>
+#include <limits>
+#include <tuple>
+#include <type_traits>
+
+#include "core/assert_cast.h"
+#include "core/column/column_nullable.h"
+#include "core/column/column_vector.h"
+#include "core/data_type/data_type.h"
+#include "core/data_type/data_type_nullable.h"
+#include "core/data_type/data_type_number.h"
+#include "core/field.h"
+#include "core/types.h"
+#include "exprs/aggregate/aggregate_function.h"
+
+namespace doris {
+
+enum class RegrFunctionKind : uint8_t {
+    regr_avgx,
+    regr_avgy,
+    regr_count,
+    regr_slope,
+    regr_intercept,
+    regr_sxx,
+    regr_syy,
+    regr_sxy,
+    regr_r2,
+};
+
+template <RegrFunctionKind kind>
+struct RegrTraits;
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_avgx> {
+    static constexpr auto name = "regr_avgx";
+    static constexpr size_t sx_level = 1;
+    static constexpr size_t sy_level = 0;
+    static constexpr bool use_sxy = false;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_avgy> {
+    static constexpr auto name = "regr_avgy";
+    static constexpr size_t sx_level = 0;
+    static constexpr size_t sy_level = 1;
+    static constexpr bool use_sxy = false;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_count> {
+    static constexpr auto name = "regr_count";
+    static constexpr size_t sx_level = 0;
+    static constexpr size_t sy_level = 0;
+    static constexpr bool use_sxy = false;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_slope> {
+    static constexpr auto name = "regr_slope";
+    static constexpr size_t sx_level = 2;
+    static constexpr size_t sy_level = 1;
+    static constexpr bool use_sxy = true;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_intercept> {
+    static constexpr auto name = "regr_intercept";
+    static constexpr size_t sx_level = 2;
+    // Keep `syy` to preserve regr_intercept's historical serialized state 
layout.
+    static constexpr size_t sy_level = 2;
+    static constexpr bool use_sxy = true;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_sxx> {
+    static constexpr auto name = "regr_sxx";
+    static constexpr size_t sx_level = 2;
+    static constexpr size_t sy_level = 0;
+    static constexpr bool use_sxy = false;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_syy> {
+    static constexpr auto name = "regr_syy";
+    static constexpr size_t sx_level = 0;
+    static constexpr size_t sy_level = 2;
+    static constexpr bool use_sxy = false;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_sxy> {
+    static constexpr auto name = "regr_sxy";
+    static constexpr size_t sx_level = 1;
+    static constexpr size_t sy_level = 1;
+    static constexpr bool use_sxy = true;
+};
+
+template <>
+struct RegrTraits<RegrFunctionKind::regr_r2> {
+    static constexpr auto name = "regr_r2";
+    static constexpr size_t sx_level = 2;
+    static constexpr size_t sy_level = 2;
+    static constexpr bool use_sxy = true;
+};
+
+template <PrimitiveType T, RegrFunctionKind kind>
+struct AggregateFunctionRegrData {
+    using Traits = RegrTraits<kind>;
+    static constexpr PrimitiveType Type = T;
+
+    static_assert(Traits::sx_level <= 2 && Traits::sy_level <= 2, "sx/sy level 
must be <= 2");
+    static_assert(!Traits::use_sxy || (Traits::sx_level > 0 && 
Traits::sy_level > 0),
+                  "sxy requires sx_level > 0 and sy_level > 0");
+
+    static constexpr bool has_sx = Traits::sx_level > 0;
+    static constexpr bool has_sy = Traits::sy_level > 0;
+    static constexpr bool has_sxx = Traits::sx_level > 1;
+    static constexpr bool has_syy = Traits::sy_level > 1;
+    static constexpr bool has_sxy = Traits::use_sxy;
+
+    static constexpr size_t k_num_moments = Traits::sx_level + 
Traits::sy_level + size_t {has_sxy};
+    static constexpr bool has_moments = k_num_moments > 0;
+    static_assert(k_num_moments <= 5, "Unexpected size of regr moment array");
+
+    using State = std::conditional_t<has_moments,
+                                     // (n, moments)
+                                     std::tuple<UInt64, std::array<Float64, 
k_num_moments>>,
+                                     // (n)
+                                     std::tuple<UInt64>>;
+
+    /**
+     * The aggregate state stores:
+     *     N   = count
+     *
+     * The following moments are stored only when enabled by RegrTraits<kind>:
+     *     Sx  = sum(X)
+     *     Sy  = sum(Y)
+     *     Sxx = sum((X-Sx/N)^2)
+     *     Syy = sum((Y-Sy/N)^2)
+     *     Sxy = sum((X-Sx/N)*(Y-Sy/N))
+     */
+    State state {};
+
+    auto& moments() {
+        static_assert(has_moments, "moments not enabled");
+        return std::get<1>(state);
+    }
+
+    const auto& moments() const {
+        static_assert(has_moments, "moments not enabled");
+        return std::get<1>(state);
+    }
+
+    static constexpr size_t sx_index() {
+        static_assert(has_sx, "sx not enabled");
+        return 0;
+    }
+
+    static constexpr size_t sy_index() {
+        static_assert(has_sy, "sy not enabled");
+        return size_t {has_sx};
+    }
+
+    static constexpr size_t sxx_index() {
+        static_assert(has_sxx, "sxx not enabled");
+        return size_t {has_sx + has_sy};
+    }
+
+    static constexpr size_t syy_index() {
+        static_assert(has_syy, "syy not enabled");
+        return size_t {has_sx + has_sy + has_sxx};
+    }
+
+    static constexpr size_t sxy_index() {
+        static_assert(has_sxy, "sxy not enabled");
+        return size_t {has_sx + has_sy + has_sxx + has_syy};
+    }
+
+    UInt64& n() { return std::get<0>(state); }
+    Float64& sx() { return moments()[sx_index()]; }
+    Float64& sy() { return moments()[sy_index()]; }
+    Float64& sxx() { return moments()[sxx_index()]; }
+    Float64& syy() { return moments()[syy_index()]; }
+    Float64& sxy() { return moments()[sxy_index()]; }
+
+    const UInt64& n() const { return std::get<0>(state); }
+    const Float64& sx() const { return moments()[sx_index()]; }
+    const Float64& sy() const { return moments()[sy_index()]; }
+    const Float64& sxx() const { return moments()[sxx_index()]; }
+    const Float64& syy() const { return moments()[syy_index()]; }
+    const Float64& sxy() const { return moments()[sxy_index()]; }
+
+    void write(BufferWritable& buf) const {
+        if constexpr (has_sx) {
+            buf.write_binary(sx());
+        }
+        if constexpr (has_sy) {
+            buf.write_binary(sy());
+        }
+        if constexpr (has_sxx) {
+            buf.write_binary(sxx());
+        }
+        if constexpr (has_syy) {
+            buf.write_binary(syy());
+        }
+        if constexpr (has_sxy) {
+            buf.write_binary(sxy());
+        }
+        buf.write_binary(n());
+    }
+
+    void read(BufferReadable& buf) {
+        if constexpr (has_sx) {
+            buf.read_binary(sx());
+        }
+        if constexpr (has_sy) {
+            buf.read_binary(sy());
+        }
+        if constexpr (has_sxx) {
+            buf.read_binary(sxx());
+        }
+        if constexpr (has_syy) {
+            buf.read_binary(syy());
+        }
+        if constexpr (has_sxy) {
+            buf.read_binary(sxy());
+        }
+        buf.read_binary(n());
+    }
+
+    void reset() {
+        if constexpr (has_moments) {
+            moments().fill({});
+        }
+        n() = {};
+    }
+
+    /**
+     * The merge function uses the Youngs-Cramer algorithm:
+     *     N   = N1 + N2
+     *     Sx  = Sx1 + Sx2
+     *     Sy  = Sy1 + Sy2
+     *     Sxx = Sxx1 + Sxx2 + N1 * N2 * (Sx1/N1 - Sx2/N2)^2 / N
+     *     Syy = Syy1 + Syy2 + N1 * N2 * (Sy1/N1 - Sy2/N2)^2 / N
+     *     Sxy = Sxy1 + Sxy2 + N1 * N2 * (Sx1/N1 - Sx2/N2) * (Sy1/N1 - Sy2/N2) 
/ N
+     */
+    void merge(const AggregateFunctionRegrData& rhs) {
+        if (rhs.n() == 0) {
+            return;
+        }
+        if (n() == 0) {
+            *this = rhs;
+            return;
+        }
+        const auto n1 = static_cast<Float64>(n());
+        const auto n2 = static_cast<Float64>(rhs.n());
+        const auto nsum = n1 + n2;
+
+        Float64 dx {};
+        Float64 dy {};
+        if constexpr (has_sxx || has_sxy) {
+            dx = sx() / n1 - rhs.sx() / n2;
+        }
+        if constexpr (has_syy || has_sxy) {
+            dy = sy() / n1 - rhs.sy() / n2;
+        }
+
+        n() += rhs.n();
+        if constexpr (has_sx) {
+            sx() += rhs.sx();
+        }
+        if constexpr (has_sy) {
+            sy() += rhs.sy();
+        }
+        if constexpr (has_sxx) {
+            sxx() += rhs.sxx() + n1 * n2 * dx * dx / nsum;
+        }
+        if constexpr (has_syy) {
+            syy() += rhs.syy() + n1 * n2 * dy * dy / nsum;
+        }
+        if constexpr (has_sxy) {
+            sxy() += rhs.sxy() + n1 * n2 * dx * dy / nsum;
+        }
+    }
+
+    /**
+     * N   = count
+     * Sx  = sum(X)
+     * Sy  = sum(Y)
+     * Sxx = sum((X-Sx/N)^2)
+     * Syy = sum((Y-Sy/N)^2)
+     * Sxy = sum((X-Sx/N)*(Y-Sy/N))
+     */
+    void add(typename PrimitiveTypeTraits<Type>::CppType value_y,
+             typename PrimitiveTypeTraits<Type>::CppType value_x) {
+        const auto x = static_cast<Float64>(value_x);
+        const auto y = static_cast<Float64>(value_y);
+
+        if constexpr (has_sx) {
+            sx() += x;
+        }
+        if constexpr (has_sy) {
+            sy() += y;
+        }
+
+        if (n() == 0) [[unlikely]] {
+            n() = 1;
+            return;
+        }
+        const auto n_old = static_cast<Float64>(n());
+        const auto n_new = n_old + 1;
+        const auto scale = 1.0 / (n_new * n_old);
+        n() += 1;
+
+        Float64 tmp_x {};
+        Float64 tmp_y {};
+        if constexpr (has_sxx || has_sxy) {
+            tmp_x = x * n_new - sx();
+        }
+        if constexpr (has_syy || has_sxy) {
+            tmp_y = y * n_new - sy();
+        }
+
+        if constexpr (has_sxx) {
+            sxx() += tmp_x * tmp_x * scale;
+        }
+        if constexpr (has_syy) {
+            syy() += tmp_y * tmp_y * scale;
+        }
+        if constexpr (has_sxy) {
+            sxy() += tmp_x * tmp_y * scale;
+        }
+    }
+
+    auto get_result() const {
+        if constexpr (kind == RegrFunctionKind::regr_count) {
+            return static_cast<Int64>(n());
+        } else if constexpr (kind == RegrFunctionKind::regr_avgx) {
+            if (n() < 1) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return sx() / static_cast<Float64>(n());
+        } else if constexpr (kind == RegrFunctionKind::regr_avgy) {
+            if (n() < 1) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return sy() / static_cast<Float64>(n());
+        } else if constexpr (kind == RegrFunctionKind::regr_slope) {
+            if (n() < 1 || sxx() == 0.0) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return sxy() / sxx();
+        } else if constexpr (kind == RegrFunctionKind::regr_intercept) {
+            if (n() < 1 || sxx() == 0.0) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return (sy() - sx() * sxy() / sxx()) / static_cast<Float64>(n());
+        } else if constexpr (kind == RegrFunctionKind::regr_sxx) {
+            if (n() < 1) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return sxx();
+        } else if constexpr (kind == RegrFunctionKind::regr_syy) {
+            if (n() < 1) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return syy();
+        } else if constexpr (kind == RegrFunctionKind::regr_sxy) {
+            if (n() < 1) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            return sxy();
+        } else if constexpr (kind == RegrFunctionKind::regr_r2) {
+            if (n() < 1 || sxx() == 0.0) {
+                return std::numeric_limits<Float64>::quiet_NaN();
+            }
+            if (syy() == 0.0) {
+                return 1.0;
+            }
+            return (sxy() * sxy()) / (sxx() * syy());
+        } else {
+            __builtin_unreachable();
+        }
+    }
+};
+
+template <PrimitiveType T, RegrFunctionKind kind, bool y_is_nullable, bool 
x_is_nullable,
+          typename Derived>
+class AggregateFunctionRegrBase
+        : public IAggregateFunctionDataHelper<AggregateFunctionRegrData<T, 
kind>, Derived> {
+public:
+    using Data = AggregateFunctionRegrData<T, kind>;
+    using InputCol = typename PrimitiveTypeTraits<Data::Type>::ColumnType;
+
+    explicit AggregateFunctionRegrBase(const DataTypes& argument_types_)
+            : IAggregateFunctionDataHelper<Data, Derived>(argument_types_) {
+        DCHECK(argument_types_.size() == 2);
+    }
+
+    String get_name() const override { return RegrTraits<kind>::name; }
+
+    // Regr aggregates only consume rows where both y and x are non-null.
+    void add(AggregateDataPtr __restrict place, const IColumn** columns, 
ssize_t row_num,
+             Arena&) const override {
+        const auto* y_column = 
get_nested_column_or_null<y_is_nullable>(columns[0], row_num);
+        if constexpr (y_is_nullable) {
+            if (y_column == nullptr) {
+                return;
+            }
+        }
+        const auto* x_column = 
get_nested_column_or_null<x_is_nullable>(columns[1], row_num);
+        if constexpr (x_is_nullable) {
+            if (x_column == nullptr) {
+                return;
+            }
+        }
+
+        this->data(place).add(y_column->get_data()[row_num], 
x_column->get_data()[row_num]);
+    }
+
+    void reset(AggregateDataPtr __restrict place) const override { 
this->data(place).reset(); }
+
+    void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs,
+               Arena&) const override {
+        this->data(place).merge(this->data(rhs));
+    }
+
+    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& 
buf) const override {
+        this->data(place).write(buf);
+    }
+
+    void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf,
+                     Arena&) const override {
+        this->data(place).read(buf);
+    }
+
+protected:
+    using IAggregateFunctionDataHelper<Data, Derived>::data;
+
+private:
+    template <bool is_nullable>
+    static ALWAYS_INLINE const InputCol* get_nested_column_or_null(const 
IColumn* col,
+                                                                   ssize_t 
row_num) {
+        if constexpr (is_nullable) {
+            const auto& nullable_column =
+                    assert_cast<const ColumnNullable&, 
TypeCheckOnRelease::DISABLE>(*col);
+            if (nullable_column.is_null_at(row_num)) {
+                return nullptr;
+            }
+            return assert_cast<const InputCol*, TypeCheckOnRelease::DISABLE>(
+                    nullable_column.get_nested_column_ptr().get());
+        } else {
+            return assert_cast<const InputCol*, 
TypeCheckOnRelease::DISABLE>(col->get_ptr().get());
+        }
+    }
+};
+
+template <PrimitiveType T, RegrFunctionKind kind, bool y_is_nullable, bool 
x_is_nullable>
+class AggregateFunctionRegr final
+        : public AggregateFunctionRegrBase<
+                  T, kind, y_is_nullable, x_is_nullable,
+                  AggregateFunctionRegr<T, kind, y_is_nullable, 
x_is_nullable>> {
+public:
+    static_assert(kind != RegrFunctionKind::regr_count,
+                  "regr_count uses the AggregateFunctionRegr specialization");
+
+    using ResultDataType = ColumnFloat64;
+    using Base =
+            AggregateFunctionRegrBase<T, kind, y_is_nullable, x_is_nullable, 
AggregateFunctionRegr>;
+
+    explicit AggregateFunctionRegr(const DataTypes& argument_types_) : 
Base(argument_types_) {}
+
+    DataTypePtr get_return_type() const override {
+        return make_nullable(std::make_shared<DataTypeFloat64>());
+    }
+
+    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& 
to) const override {
+        auto& nullable_column = assert_cast<ColumnNullable&>(to);
+        auto& nested_column = 
assert_cast<ResultDataType&>(nullable_column.get_nested_column());
+        const Float64 result = this->data(place).get_result();
+        if (std::isnan(result)) {
+            nullable_column.get_null_map_data().push_back(1);
+            nested_column.insert_default();
+        } else {
+            nullable_column.get_null_map_data().push_back(0);
+            nested_column.get_data().push_back(result);
+        }
+    }
+};
+
+template <PrimitiveType T, bool y_is_nullable, bool x_is_nullable>
+class AggregateFunctionRegr<T, RegrFunctionKind::regr_count, y_is_nullable, 
x_is_nullable> final
+        : public AggregateFunctionRegrBase<T, RegrFunctionKind::regr_count, 
y_is_nullable,
+                                           x_is_nullable,
+                                           AggregateFunctionRegr<T, 
RegrFunctionKind::regr_count,
+                                                                 
y_is_nullable, x_is_nullable>> {
+public:
+    using ResultDataType = ColumnInt64;
+    using Base = AggregateFunctionRegrBase<T, RegrFunctionKind::regr_count, 
y_is_nullable,
+                                           x_is_nullable, 
AggregateFunctionRegr>;
+
+    explicit AggregateFunctionRegr(const DataTypes& argument_types_) : 
Base(argument_types_) {}
+
+    DataTypePtr get_return_type() const override { return 
std::make_shared<DataTypeInt64>(); }
+
+    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& 
to) const override {
+        auto& result_column = assert_cast<ResultDataType&>(to);
+        result_column.get_data().push_back(this->data(place).get_result());
+    }
+};
+
+} // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_regr_union.cpp 
b/be/src/exprs/aggregate/aggregate_function_regr_union.cpp
deleted file mode 100644
index ec58de86170..00000000000
--- a/be/src/exprs/aggregate/aggregate_function_regr_union.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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 "exprs/aggregate/aggregate_function_regr_union.h"
-
-#include "core/data_type/data_type.h"
-#include "exprs/aggregate/aggregate_function.h"
-#include "exprs/aggregate/aggregate_function_simple_factory.h"
-#include "exprs/aggregate/helpers.h"
-
-namespace doris {
-
-template <template <PrimitiveType> class StatFunctionTemplate>
-AggregateFunctionPtr create_aggregate_function_regr(const std::string& name,
-                                                    const DataTypes& 
argument_types,
-                                                    const DataTypePtr& 
result_type,
-                                                    const bool 
result_is_nullable,
-                                                    const 
AggregateFunctionAttr& attr) {
-    bool y_nullable_input = argument_types[0]->is_nullable();
-    bool x_nullable_input = argument_types[1]->is_nullable();
-    if (y_nullable_input) {
-        if (x_nullable_input) {
-            return creator_without_type::create_ignore_nullable<
-                    
AggregateFunctionRegrSimple<StatFunctionTemplate<TYPE_DOUBLE>, true, true>>(
-                    argument_types, result_is_nullable, attr);
-        } else {
-            return creator_without_type::create_ignore_nullable<
-                    
AggregateFunctionRegrSimple<StatFunctionTemplate<TYPE_DOUBLE>, true, false>>(
-                    argument_types, result_is_nullable, attr);
-        }
-    } else {
-        if (x_nullable_input) {
-            return creator_without_type::create_ignore_nullable<
-                    
AggregateFunctionRegrSimple<StatFunctionTemplate<TYPE_DOUBLE>, false, true>>(
-                    argument_types, result_is_nullable, attr);
-        } else {
-            return creator_without_type::create_ignore_nullable<
-                    
AggregateFunctionRegrSimple<StatFunctionTemplate<TYPE_DOUBLE>, false, false>>(
-                    argument_types, result_is_nullable, attr);
-        }
-    }
-}
-
-void register_aggregate_function_regr_union(AggregateFunctionSimpleFactory& 
factory) {
-    factory.register_function_both("regr_slope", 
create_aggregate_function_regr<RegrSlopeFunc>);
-    factory.register_function_both("regr_intercept",
-                                   
create_aggregate_function_regr<RegrInterceptFunc>);
-    factory.register_function_both("regr_sxx", 
create_aggregate_function_regr<RegrSxxFunc>);
-    factory.register_function_both("regr_syy", 
create_aggregate_function_regr<RegrSyyFunc>);
-    factory.register_function_both("regr_sxy", 
create_aggregate_function_regr<RegrSxyFunc>);
-}
-} // namespace doris
\ No newline at end of file
diff --git a/be/src/exprs/aggregate/aggregate_function_regr_union.h 
b/be/src/exprs/aggregate/aggregate_function_regr_union.h
deleted file mode 100644
index f63fa82de44..00000000000
--- a/be/src/exprs/aggregate/aggregate_function_regr_union.h
+++ /dev/null
@@ -1,389 +0,0 @@
-// 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.
-
-#pragma once
-
-#include <cmath>
-
-#include "core/assert_cast.h"
-#include "core/column/column_nullable.h"
-#include "core/column/column_vector.h"
-#include "core/data_type/data_type.h"
-#include "core/data_type/data_type_nullable.h"
-#include "core/data_type/data_type_number.h"
-#include "core/field.h"
-#include "core/types.h"
-#include "exprs/aggregate/aggregate_function.h"
-
-namespace doris {
-
-template <PrimitiveType T,
-          // requires Sx and Sy
-          bool NeedSxy,
-          // level 1: Sx
-          // level 2: Sxx
-          size_t SxLevel = size_t {NeedSxy},
-          // level 1: Sy
-          // level 2: Syy
-          size_t SyLevel = size_t {NeedSxy}>
-struct AggregateFunctionRegrData {
-    static constexpr PrimitiveType Type = T;
-
-    static_assert(!NeedSxy || (SxLevel > 0 && SyLevel > 0),
-                  "NeedSxy requires SxLevel > 0 and SyLevel > 0");
-    static_assert(SxLevel <= 2 && SyLevel <= 2, "Sx/Sy level must be <= 2");
-
-    static constexpr bool need_sx = SxLevel > 0;
-    static constexpr bool need_sy = SyLevel > 0;
-    static constexpr bool need_sxx = SxLevel > 1;
-    static constexpr bool need_syy = SyLevel > 1;
-    static constexpr bool need_sxy = NeedSxy;
-
-    static constexpr size_t kMomentSize = SxLevel + SyLevel + size_t 
{need_sxy};
-    static_assert(kMomentSize > 0 && kMomentSize <= 5, "Unexpected size of 
regr moment array");
-
-    /**
-     * The moments array is:
-     *     Sx  = sum(X)
-     *     Sy  = sum(Y)
-     *     Sxx = sum((X-Sx/N)^2)
-     *     Syy = sum((Y-Sy/N)^2)
-     *     Sxy = sum((X-Sx/N)*(Y-Sy/N))
-    */
-    std::array<Float64, kMomentSize> moments {};
-    UInt64 n {};
-
-    static constexpr size_t idx_sx() {
-        static_assert(need_sx, "sx not enabled");
-        return 0;
-    }
-    static constexpr size_t idx_sy() {
-        static_assert(need_sy, "sy not enabled");
-        return size_t {need_sx};
-    }
-    static constexpr size_t idx_sxx() {
-        static_assert(need_sxx, "sxx not enabled");
-        return size_t {need_sx + need_sy};
-    }
-    static constexpr size_t idx_syy() {
-        static_assert(need_syy, "syy not enabled");
-        return size_t {need_sx + need_sy + need_sxx};
-    }
-    static constexpr size_t idx_sxy() {
-        static_assert(need_sxy, "sxy not enabled");
-        return size_t {need_sx + need_sy + need_sxx + need_syy};
-    }
-
-    Float64& sx() { return moments[idx_sx()]; }
-    Float64& sy() { return moments[idx_sy()]; }
-    Float64& sxx() { return moments[idx_sxx()]; }
-    Float64& syy() { return moments[idx_syy()]; }
-    Float64& sxy() { return moments[idx_sxy()]; }
-
-    const Float64& sx() const { return moments[idx_sx()]; }
-    const Float64& sy() const { return moments[idx_sy()]; }
-    const Float64& sxx() const { return moments[idx_sxx()]; }
-    const Float64& syy() const { return moments[idx_syy()]; }
-    const Float64& sxy() const { return moments[idx_sxy()]; }
-
-    void write(BufferWritable& buf) const {
-        if constexpr (need_sx) {
-            buf.write_binary(sx());
-        }
-        if constexpr (need_sy) {
-            buf.write_binary(sy());
-        }
-        if constexpr (need_sxx) {
-            buf.write_binary(sxx());
-        }
-        if constexpr (need_syy) {
-            buf.write_binary(syy());
-        }
-        if constexpr (need_sxy) {
-            buf.write_binary(sxy());
-        }
-        buf.write_binary(n);
-    }
-
-    void read(BufferReadable& buf) {
-        if constexpr (need_sx) {
-            buf.read_binary(sx());
-        }
-        if constexpr (need_sy) {
-            buf.read_binary(sy());
-        }
-        if constexpr (need_sxx) {
-            buf.read_binary(sxx());
-        }
-        if constexpr (need_syy) {
-            buf.read_binary(syy());
-        }
-        if constexpr (need_sxy) {
-            buf.read_binary(sxy());
-        }
-        buf.read_binary(n);
-    }
-
-    void reset() {
-        moments.fill({});
-        n = {};
-    }
-
-    /**
-     * The merge function uses the Youngs–Cramer algorithm:
-     *     N   = N1 + N2
-     *     Sx  = Sx1 + Sx2
-     *     Sy  = Sy1 + Sy2
-     *     Sxx = Sxx1 + Sxx2 + N1 * N2 * (Sx1/N1 - Sx2/N2)^2 / N
-     *     Syy = Syy1 + Syy2 + N1 * N2 * (Sy1/N1 - Sy2/N2)^2 / N
-     *     Sxy = Sxy1 + Sxy2 + N1 * N2 * (Sx1/N1 - Sx2/N2) * (Sy1/N1 - Sy2/N2) 
/ N
-     */
-    void merge(const AggregateFunctionRegrData& rhs) {
-        if (rhs.n == 0) {
-            return;
-        }
-        if (n == 0) {
-            *this = rhs;
-            return;
-        }
-        const auto n1 = static_cast<Float64>(n);
-        const auto n2 = static_cast<Float64>(rhs.n);
-        const auto nsum = n1 + n2;
-
-        Float64 dx {};
-        Float64 dy {};
-        if constexpr (need_sxx || need_sxy) {
-            dx = sx() / n1 - rhs.sx() / n2;
-        }
-        if constexpr (need_syy || need_sxy) {
-            dy = sy() / n1 - rhs.sy() / n2;
-        }
-
-        n += rhs.n;
-        if constexpr (need_sx) {
-            sx() += rhs.sx();
-        }
-        if constexpr (need_sy) {
-            sy() += rhs.sy();
-        }
-        if constexpr (need_sxx) {
-            sxx() += rhs.sxx() + n1 * n2 * dx * dx / nsum;
-        }
-        if constexpr (need_syy) {
-            syy() += rhs.syy() + n1 * n2 * dy * dy / nsum;
-        }
-        if constexpr (need_sxy) {
-            sxy() += rhs.sxy() + n1 * n2 * dx * dy / nsum;
-        }
-    }
-
-    /**
-     * N
-     * Sx  = sum(X)
-     * Sy  = sum(Y)
-     * Sxx = sum((X-Sx/N)^2)
-     * Syy = sum((Y-Sy/N)^2)
-     * Sxy = sum((X-Sx/N)*(Y-Sy/N))
-     */
-    void add(typename PrimitiveTypeTraits<T>::CppType value_y,
-             typename PrimitiveTypeTraits<T>::CppType value_x) {
-        const auto x = static_cast<Float64>(value_x);
-        const auto y = static_cast<Float64>(value_y);
-
-        if constexpr (need_sx) {
-            sx() += x;
-        }
-        if constexpr (need_sy) {
-            sy() += y;
-        }
-
-        if (n == 0) [[unlikely]] {
-            n = 1;
-            return;
-        }
-        const auto n_old = static_cast<Float64>(n);
-        const auto n_new = n_old + 1;
-        const auto scale = 1.0 / (n_new * n_old);
-        n += 1;
-
-        Float64 tmp_x {};
-        Float64 tmp_y {};
-        if constexpr (need_sxx || need_sxy) {
-            tmp_x = x * n_new - sx();
-        }
-        if constexpr (need_syy || need_sxy) {
-            tmp_y = y * n_new - sy();
-        }
-
-        if constexpr (need_sxx) {
-            sxx() += tmp_x * tmp_x * scale;
-        }
-        if constexpr (need_syy) {
-            syy() += tmp_y * tmp_y * scale;
-        }
-        if constexpr (need_sxy) {
-            sxy() += tmp_x * tmp_y * scale;
-        }
-    }
-};
-
-template <PrimitiveType T>
-struct RegrSlopeFunc : AggregateFunctionRegrData<T, true, 2, 1> {
-    static constexpr const char* name = "regr_slope";
-
-    Float64 get_result() const {
-        if (this->n < 1 || this->sxx() == 0.0) {
-            return std::numeric_limits<Float64>::quiet_NaN();
-        }
-        return this->sxy() / this->sxx();
-    }
-};
-
-template <PrimitiveType T>
-struct RegrInterceptFunc : AggregateFunctionRegrData<T, true, 2, 2> {
-    static constexpr const char* name = "regr_intercept";
-
-    Float64 get_result() const {
-        if (this->n < 1 || this->sxx() == 0.0) {
-            return std::numeric_limits<Float64>::quiet_NaN();
-        }
-        return (this->sy() - this->sx() * this->sxy() / this->sxx()) /
-               static_cast<Float64>(this->n);
-    }
-};
-
-template <PrimitiveType T>
-struct RegrSxxFunc : AggregateFunctionRegrData<T, false, 2, 0> {
-    static constexpr const char* name = "regr_sxx";
-
-    Float64 get_result() const {
-        if (this->n < 1) {
-            return std::numeric_limits<Float64>::quiet_NaN();
-        }
-        return this->sxx();
-    }
-};
-
-template <PrimitiveType T>
-struct RegrSyyFunc : AggregateFunctionRegrData<T, false, 0, 2> {
-    static constexpr const char* name = "regr_syy";
-
-    Float64 get_result() const {
-        if (this->n < 1) {
-            return std::numeric_limits<Float64>::quiet_NaN();
-        }
-        return this->syy();
-    }
-};
-
-template <PrimitiveType T>
-struct RegrSxyFunc : AggregateFunctionRegrData<T, true, 1, 1> {
-    static constexpr const char* name = "regr_sxy";
-
-    Float64 get_result() const {
-        if (this->n < 1) {
-            return std::numeric_limits<Float64>::quiet_NaN();
-        }
-        return this->sxy();
-    }
-};
-
-template <typename RegrFunc, bool y_nullable, bool x_nullable>
-class AggregateFunctionRegrSimple
-        : public IAggregateFunctionDataHelper<
-                  RegrFunc, AggregateFunctionRegrSimple<RegrFunc, y_nullable, 
x_nullable>> {
-public:
-    using InputCol = typename PrimitiveTypeTraits<RegrFunc::Type>::ColumnType;
-    using ResultCol = ColumnFloat64;
-
-    explicit AggregateFunctionRegrSimple(const DataTypes& argument_types_)
-            : IAggregateFunctionDataHelper<
-                      RegrFunc, AggregateFunctionRegrSimple<RegrFunc, 
y_nullable, x_nullable>>(
-                      argument_types_) {
-        DCHECK(!argument_types_.empty());
-    }
-
-    String get_name() const override { return RegrFunc::name; }
-
-    DataTypePtr get_return_type() const override {
-        return make_nullable(std::make_shared<DataTypeFloat64>());
-    }
-
-    void add(AggregateDataPtr __restrict place, const IColumn** columns, 
ssize_t row_num,
-             Arena&) const override {
-        const auto* y_col = nested_or_null<y_nullable>(columns[0], row_num);
-        if constexpr (y_nullable) {
-            if (y_col == nullptr) {
-                return;
-            }
-        }
-        const auto* x_col = nested_or_null<x_nullable>(columns[1], row_num);
-        if constexpr (x_nullable) {
-            if (x_col == nullptr) {
-                return;
-            }
-        }
-
-        this->data(place).add(y_col->get_data()[row_num], 
x_col->get_data()[row_num]);
-    }
-
-    void reset(AggregateDataPtr __restrict place) const override { 
this->data(place).reset(); }
-
-    void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs,
-               Arena&) const override {
-        this->data(place).merge(this->data(rhs));
-    }
-
-    void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& 
buf) const override {
-        this->data(place).write(buf);
-    }
-
-    void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf,
-                     Arena&) const override {
-        this->data(place).read(buf);
-    }
-
-    void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& 
to) const override {
-        const auto& data = this->data(place);
-        auto& dst_column_with_nullable = assert_cast<ColumnNullable&>(to);
-        auto& dst_column = 
assert_cast<ResultCol&>(dst_column_with_nullable.get_nested_column());
-        Float64 result = data.get_result();
-        if (std::isnan(result)) {
-            dst_column_with_nullable.get_null_map_data().push_back(1);
-            dst_column.insert_default();
-        } else {
-            dst_column_with_nullable.get_null_map_data().push_back(0);
-            dst_column.get_data().push_back(result);
-        }
-    }
-
-private:
-    template <bool Nullable>
-    static ALWAYS_INLINE const InputCol* nested_or_null(const IColumn* col, 
ssize_t row_num) {
-        if constexpr (Nullable) {
-            const auto& c = assert_cast<const ColumnNullable&, 
TypeCheckOnRelease::DISABLE>(*col);
-            if (c.is_null_at(row_num)) {
-                return nullptr;
-            }
-            return assert_cast<const InputCol*, TypeCheckOnRelease::DISABLE>(
-                    c.get_nested_column_ptr().get());
-        } else {
-            return assert_cast<const InputCol*, 
TypeCheckOnRelease::DISABLE>(col->get_ptr().get());
-        }
-    }
-};
-} // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp 
b/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
index 255d6aa477c..b9851bd4752 100644
--- a/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
+++ b/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
@@ -56,7 +56,7 @@ void 
register_aggregate_function_percentile_old(AggregateFunctionSimpleFactory&
 void register_aggregate_function_window_funnel(AggregateFunctionSimpleFactory& 
factory);
 void 
register_aggregate_function_window_funnel_old(AggregateFunctionSimpleFactory& 
factory);
 void 
register_aggregate_function_window_funnel_v2(AggregateFunctionSimpleFactory& 
factory);
-void register_aggregate_function_regr_union(AggregateFunctionSimpleFactory& 
factory);
+void register_aggregate_function_regr(AggregateFunctionSimpleFactory& factory);
 void register_aggregate_function_retention(AggregateFunctionSimpleFactory& 
factory);
 void 
register_aggregate_function_percentile_approx(AggregateFunctionSimpleFactory& 
factory);
 void 
register_aggregate_function_orthogonal_bitmap(AggregateFunctionSimpleFactory& 
factory);
@@ -110,7 +110,7 @@ AggregateFunctionSimpleFactory& 
AggregateFunctionSimpleFactory::instance() {
         register_aggregate_function_window_funnel(instance);
         register_aggregate_function_window_funnel_old(instance);
         register_aggregate_function_window_funnel_v2(instance);
-        register_aggregate_function_regr_union(instance);
+        register_aggregate_function_regr(instance);
         register_aggregate_function_retention(instance);
         register_aggregate_function_orthogonal_bitmap(instance);
         register_aggregate_function_collect_list(instance);
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 31cd3860270..3104a89eb8d 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
@@ -75,7 +75,11 @@ import 
org.apache.doris.nereids.trees.expressions.functions.agg.PercentileApprox
 import 
org.apache.doris.nereids.trees.expressions.functions.agg.PercentileArray;
 import 
org.apache.doris.nereids.trees.expressions.functions.agg.PercentileReservoir;
 import org.apache.doris.nereids.trees.expressions.functions.agg.QuantileUnion;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrAvgx;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrAvgy;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrCount;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrIntercept;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrR2;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrSlope;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrSxx;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrSxy;
@@ -175,7 +179,11 @@ public class BuiltinAggregateFunctions implements 
FunctionHelper {
                 agg(PercentileApproxWeighted.class, 
"percentile_approx_weighted"),
                 agg(PercentileArray.class, "percentile_array"),
                 agg(QuantileUnion.class, "quantile_union"),
+                agg(RegrAvgx.class, "regr_avgx"),
+                agg(RegrAvgy.class, "regr_avgy"),
+                agg(RegrCount.class, "regr_count"),
                 agg(RegrIntercept.class, "regr_intercept"),
+                agg(RegrR2.class, "regr_r2"),
                 agg(RegrSlope.class, "regr_slope"),
                 agg(RegrSxx.class, "regr_sxx"),
                 agg(RegrSxy.class, "regr_sxy"),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrAvgx.java
similarity index 61%
copy from 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
copy to 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrAvgx.java
index b647269eab0..c1f11c0321d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrAvgx.java
@@ -18,14 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -33,49 +30,34 @@ import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
-/** regr_sxy agg function. */
-public class RegrSxy extends AggregateFunction
+/** regr_avgx agg function. */
+public class RegrAvgx extends AggregateFunction
         implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, 
DoubleType.INSTANCE));
 
-    public RegrSxy(Expression arg0, Expression arg1) {
+    public RegrAvgx(Expression arg0, Expression arg1) {
         this(false, arg0, arg1);
     }
 
-    public RegrSxy(boolean distinct, Expression arg0, Expression arg1) {
-        super("regr_sxy", distinct, arg0, arg1);
+    public RegrAvgx(boolean distinct, Expression arg0, Expression arg1) {
+        super("regr_avgx", distinct, arg0, arg1);
     }
 
-    public RegrSxy(AggregateFunctionParams functionParams) {
+    public RegrAvgx(AggregateFunctionParams functionParams) {
         super(functionParams);
     }
 
     @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for second 
parameter: " + toSql());
-        }
-    }
-
-    @Override
-    public RegrSxy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
+    public RegrAvgx withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
         Preconditions.checkArgument(children.size() == 2);
-        return new RegrSxy(getFunctionParams(distinct, children));
+        return new RegrAvgx(getFunctionParams(distinct, children));
     }
 
     @Override
     public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
-        return visitor.visitRegrSxy(this, context);
+        return visitor.visitRegrAvgx(this, context);
     }
 
     @Override
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrAvgy.java
similarity index 61%
copy from 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
copy to 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrAvgy.java
index b647269eab0..1491cf71b81 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrAvgy.java
@@ -18,14 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -33,49 +30,34 @@ import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
-/** regr_sxy agg function. */
-public class RegrSxy extends AggregateFunction
+/** regr_avgy agg function. */
+public class RegrAvgy extends AggregateFunction
         implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, 
DoubleType.INSTANCE));
 
-    public RegrSxy(Expression arg0, Expression arg1) {
+    public RegrAvgy(Expression arg0, Expression arg1) {
         this(false, arg0, arg1);
     }
 
-    public RegrSxy(boolean distinct, Expression arg0, Expression arg1) {
-        super("regr_sxy", distinct, arg0, arg1);
+    public RegrAvgy(boolean distinct, Expression arg0, Expression arg1) {
+        super("regr_avgy", distinct, arg0, arg1);
     }
 
-    public RegrSxy(AggregateFunctionParams functionParams) {
+    public RegrAvgy(AggregateFunctionParams functionParams) {
         super(functionParams);
     }
 
     @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for second 
parameter: " + toSql());
-        }
-    }
-
-    @Override
-    public RegrSxy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
+    public RegrAvgy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
         Preconditions.checkArgument(children.size() == 2);
-        return new RegrSxy(getFunctionParams(distinct, children));
+        return new RegrAvgy(getFunctionParams(distinct, children));
     }
 
     @Override
     public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
-        return visitor.visitRegrSxy(this, context);
+        return visitor.visitRegrAvgy(this, context);
     }
 
     @Override
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrCount.java
similarity index 57%
copy from 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
copy to 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrCount.java
index b647269eab0..fba0645428e 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrCount.java
@@ -18,14 +18,12 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
-import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.BigIntType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -33,49 +31,39 @@ import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
-/** regr_sxy agg function. */
-public class RegrSxy extends AggregateFunction
-        implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable {
+/** regr_count agg function. */
+public class RegrCount extends NotNullableAggregateFunction
+        implements BinaryExpression, ExplicitlyCastableSignature {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
-            
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, 
DoubleType.INSTANCE));
+            
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE, 
DoubleType.INSTANCE));
 
-    public RegrSxy(Expression arg0, Expression arg1) {
+    public RegrCount(Expression arg0, Expression arg1) {
         this(false, arg0, arg1);
     }
 
-    public RegrSxy(boolean distinct, Expression arg0, Expression arg1) {
-        super("regr_sxy", distinct, arg0, arg1);
+    public RegrCount(boolean distinct, Expression arg0, Expression arg1) {
+        super("regr_count", distinct, arg0, arg1);
     }
 
-    public RegrSxy(AggregateFunctionParams functionParams) {
+    public RegrCount(AggregateFunctionParams functionParams) {
         super(functionParams);
     }
 
     @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for second 
parameter: " + toSql());
-        }
+    public RegrCount withDistinctAndChildren(boolean distinct, 
List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 2);
+        return new RegrCount(getFunctionParams(distinct, children));
     }
 
     @Override
-    public RegrSxy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
-        Preconditions.checkArgument(children.size() == 2);
-        return new RegrSxy(getFunctionParams(distinct, children));
+    public Expression resultForEmptyInput() {
+        return new BigIntLiteral(0);
     }
 
     @Override
     public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
-        return visitor.visitRegrSxy(this, context);
+        return visitor.visitRegrCount(this, context);
     }
 
     @Override
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrIntercept.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrIntercept.java
index 7b37844d43b..81afd0441b0 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrIntercept.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrIntercept.java
@@ -18,13 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -61,19 +59,6 @@ public class RegrIntercept extends AggregateFunction
         super(functionParams);
     }
 
-    @Override
-    public void checkLegalityBeforeTypeCoercion() throws AnalysisException {
-        DataType arg0Type = left().getDataType();
-        DataType arg1Type = right().getDataType();
-        if ((!arg0Type.isNumericType() && !arg0Type.isNullType())
-                || arg0Type.isOnlyMetricType()) {
-            throw new AnalysisException("regr_intercept requires numeric for 
first parameter: " + toSql());
-        } else if ((!arg1Type.isNumericType() && !arg1Type.isNullType())
-                || arg1Type.isOnlyMetricType()) {
-            throw new AnalysisException("regr_intercept requires numeric for 
second parameter: " + toSql());
-        }
-    }
-
     @Override
     public RegrIntercept withDistinctAndChildren(boolean distinct, 
List<Expression> children) {
         Preconditions.checkArgument(children.size() == 2);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrR2.java
similarity index 61%
copy from 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
copy to 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrR2.java
index b647269eab0..2ae74a8628c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrR2.java
@@ -18,14 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -33,49 +30,34 @@ import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
-/** regr_sxy agg function. */
-public class RegrSxy extends AggregateFunction
+/** regr_r2 agg function. */
+public class RegrR2 extends AggregateFunction
         implements BinaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable {
 
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, 
DoubleType.INSTANCE));
 
-    public RegrSxy(Expression arg0, Expression arg1) {
+    public RegrR2(Expression arg0, Expression arg1) {
         this(false, arg0, arg1);
     }
 
-    public RegrSxy(boolean distinct, Expression arg0, Expression arg1) {
-        super("regr_sxy", distinct, arg0, arg1);
+    public RegrR2(boolean distinct, Expression arg0, Expression arg1) {
+        super("regr_r2", distinct, arg0, arg1);
     }
 
-    public RegrSxy(AggregateFunctionParams functionParams) {
+    public RegrR2(AggregateFunctionParams functionParams) {
         super(functionParams);
     }
 
     @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for second 
parameter: " + toSql());
-        }
-    }
-
-    @Override
-    public RegrSxy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
+    public RegrR2 withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
         Preconditions.checkArgument(children.size() == 2);
-        return new RegrSxy(getFunctionParams(distinct, children));
+        return new RegrR2(getFunctionParams(distinct, children));
     }
 
     @Override
     public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
-        return visitor.visitRegrSxy(this, context);
+        return visitor.visitRegrR2(this, context);
     }
 
     @Override
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSlope.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSlope.java
index a3e76dea3cd..fc964d317f7 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSlope.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSlope.java
@@ -18,13 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -61,19 +59,6 @@ public class RegrSlope extends AggregateFunction
         super(functionParams);
     }
 
-    @Override
-    public void checkLegalityBeforeTypeCoercion() throws AnalysisException {
-        DataType arg0Type = left().getDataType();
-        DataType arg1Type = right().getDataType();
-        if ((!arg0Type.isNumericType() && !arg0Type.isNullType())
-                || arg0Type.isOnlyMetricType()) {
-            throw new AnalysisException("regr_slope requires numeric for first 
parameter: " + toSql());
-        } else if ((!arg1Type.isNumericType() && !arg1Type.isNullType())
-                || arg1Type.isOnlyMetricType()) {
-            throw new AnalysisException("regr_slope requires numeric for 
second parameter: " + toSql());
-        }
-    }
-
     @Override
     public RegrSlope withDistinctAndChildren(boolean distinct, 
List<Expression> children) {
         Preconditions.checkArgument(children.size() == 2);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxx.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxx.java
index e324a538d0b..28f37781903 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxx.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxx.java
@@ -18,14 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -52,21 +49,6 @@ public class RegrSxx extends AggregateFunction
         super(functionParams);
     }
 
-    @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_sxx requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_sxx requires numeric for second 
parameter: " + toSql());
-        }
-    }
-
     @Override
     public RegrSxx withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
         Preconditions.checkArgument(children.size() == 2);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
index b647269eab0..39dd7dd2d84 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSxy.java
@@ -18,14 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -52,21 +49,6 @@ public class RegrSxy extends AggregateFunction
         super(functionParams);
     }
 
-    @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_sxy requires numeric for second 
parameter: " + toSql());
-        }
-    }
-
     @Override
     public RegrSxy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
         Preconditions.checkArgument(children.size() == 2);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSyy.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSyy.java
index 5ab7d579505..f1226818208 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSyy.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/RegrSyy.java
@@ -18,14 +18,11 @@
 package org.apache.doris.nereids.trees.expressions.functions.agg;
 
 import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.catalog.Type;
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
-import org.apache.doris.nereids.types.DataType;
 import org.apache.doris.nereids.types.DoubleType;
 
 import com.google.common.base.Preconditions;
@@ -52,21 +49,6 @@ public class RegrSyy extends AggregateFunction
         super(functionParams);
     }
 
-    @Override
-    public void checkLegalityBeforeTypeCoercion() {
-        DataType yType = left().getDataType();
-        DataType xType = right().getDataType();
-        if (yType.isOnlyMetricType() || xType.isOnlyMetricType()) {
-            throw new AnalysisException(Type.OnlyMetricTypeErrorMsg);
-        }
-        if (!yType.isNumericType() && !yType.isNullType()) {
-            throw new AnalysisException("regr_syy requires numeric for first 
parameter: " + toSql());
-        }
-        if (!xType.isNumericType() && !xType.isNullType()) {
-            throw new AnalysisException("regr_syy requires numeric for second 
parameter: " + toSql());
-        }
-    }
-
     @Override
     public RegrSyy withDistinctAndChildren(boolean distinct, List<Expression> 
children) {
         Preconditions.checkArgument(children.size() == 2);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
index 9bd117d4c09..37bc0697268 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
@@ -73,7 +73,11 @@ import 
org.apache.doris.nereids.trees.expressions.functions.agg.PercentileApprox
 import 
org.apache.doris.nereids.trees.expressions.functions.agg.PercentileArray;
 import 
org.apache.doris.nereids.trees.expressions.functions.agg.PercentileReservoir;
 import org.apache.doris.nereids.trees.expressions.functions.agg.QuantileUnion;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrAvgx;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrAvgy;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrCount;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrIntercept;
+import org.apache.doris.nereids.trees.expressions.functions.agg.RegrR2;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrSlope;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrSxx;
 import org.apache.doris.nereids.trees.expressions.functions.agg.RegrSxy;
@@ -325,10 +329,26 @@ public interface AggregateFunctionVisitor<R, C> {
         return visitAggregateFunction(quantileUnion, context);
     }
 
+    default R visitRegrAvgx(RegrAvgx regrAvgx, C context) {
+        return visitAggregateFunction(regrAvgx, context);
+    }
+
+    default R visitRegrAvgy(RegrAvgy regrAvgy, C context) {
+        return visitAggregateFunction(regrAvgy, context);
+    }
+
+    default R visitRegrCount(RegrCount regrCount, C context) {
+        return visitAggregateFunction(regrCount, context);
+    }
+
     default R visitRegrIntercept(RegrIntercept regrIntercept, C context) {
         return visitAggregateFunction(regrIntercept, context);
     }
 
+    default R visitRegrR2(RegrR2 regrR2, C context) {
+        return visitAggregateFunction(regrR2, context);
+    }
+
     default R visitRegrSlope(RegrSlope regrSlope, C context) {
         return visitAggregateFunction(regrSlope, context);
     }
diff --git a/regression-test/data/query_p0/aggregate/test_regr_avgx.out 
b/regression-test/data/query_p0/aggregate/test_regr_avgx.out
new file mode 100644
index 00000000000..5a1a75c0ec7
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/test_regr_avgx.out
@@ -0,0 +1,63 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql_empty_1 --
+\N
+
+-- !sql_empty_2 --
+
+-- !sql_int_1 --
+4
+
+-- !sql_int_2 --
+1      10      10
+2      2       2
+3      2.5     2.5
+5      5       5
+
+-- !sql_int_3 --
+2
+
+-- !sql_int_4 --
+2
+
+-- !sql_int_5 --
+3
+
+-- !sql_int_6 --
+\N
+
+-- !sql_double_1 --
+4.344444444444445
+
+-- !sql_double_2 --
+1      10.5    10.5
+2      2.2     2.2
+3      2.75    2.75
+5      5.5     5.5
+
+-- !sql_double_3 --
+2.2
+
+-- !sql_double_4 --
+2.2
+
+-- !sql_double_5 --
+3
+
+-- !sql_double_6 --
+\N
+
+-- !sql_string_1 --
+3
+
+-- !sql_string_2 --
+3
+
+-- !sql_bool_1 --
+0
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git a/regression-test/data/query_p0/aggregate/test_regr_avgy.out 
b/regression-test/data/query_p0/aggregate/test_regr_avgy.out
new file mode 100644
index 00000000000..f708d6651dc
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/test_regr_avgy.out
@@ -0,0 +1,63 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql_empty_1 --
+\N
+
+-- !sql_empty_2 --
+
+-- !sql_int_1 --
+5.555555555555555
+
+-- !sql_int_2 --
+1      20      20
+2      4       4
+3      6       6
+5      2       2
+
+-- !sql_int_3 --
+4
+
+-- !sql_int_4 --
+10
+
+-- !sql_int_5 --
+4
+
+-- !sql_int_6 --
+\N
+
+-- !sql_double_1 --
+5.788888888888889
+
+-- !sql_double_2 --
+1      20.5    20.5
+2      4.2     4.2
+3      6.2     6.2
+5      2.2     2.2
+
+-- !sql_double_3 --
+4.2
+
+-- !sql_double_4 --
+10
+
+-- !sql_double_5 --
+4.2
+
+-- !sql_double_6 --
+\N
+
+-- !sql_string_1 --
+5
+
+-- !sql_string_2 --
+1
+
+-- !sql_bool_1 --
+1
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git a/regression-test/data/query_p0/aggregate/test_regr_count.out 
b/regression-test/data/query_p0/aggregate/test_regr_count.out
new file mode 100644
index 00000000000..74dc4da1e43
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/test_regr_count.out
@@ -0,0 +1,63 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql_empty_1 --
+0
+
+-- !sql_empty_2 --
+
+-- !sql_int_1 --
+9
+
+-- !sql_int_2 --
+1      1       1
+2      3       3
+3      2       2
+5      3       3
+
+-- !sql_int_3 --
+3
+
+-- !sql_int_4 --
+3
+
+-- !sql_int_5 --
+3
+
+-- !sql_int_6 --
+0
+
+-- !sql_double_1 --
+9
+
+-- !sql_double_2 --
+1      1       1
+2      3       3
+3      2       2
+5      3       3
+
+-- !sql_double_3 --
+3
+
+-- !sql_double_4 --
+3
+
+-- !sql_double_5 --
+3
+
+-- !sql_double_6 --
+0
+
+-- !sql_string_1 --
+1
+
+-- !sql_string_2 --
+1
+
+-- !sql_bool_1 --
+1
+
+-- !sql_null_1 --
+0
+
+-- !sql_null_2 --
+0
+
diff --git a/regression-test/data/query_p0/aggregate/test_regr_intercept.out 
b/regression-test/data/query_p0/aggregate/test_regr_intercept.out
index ee0916564fe..192d89a4839 100644
--- a/regression-test/data/query_p0/aggregate/test_regr_intercept.out
+++ b/regression-test/data/query_p0/aggregate/test_regr_intercept.out
@@ -11,13 +11,13 @@
 \N
 
 -- !sql_int_3 --
-5.512931034482762
+5.512931034482759
 
 -- !sql_int_4 --
-5.512931034482759
+5.512931034482757
 
 -- !sql_int_5 --
-5.512931034482759
+5.512931034482757
 
 -- !sql_int_6 --
 10
@@ -58,7 +58,7 @@
 \N
 
 -- !sql_double_3 --
-5.488775193742422
+5.488775193742424
 
 -- !sql_double_3 --
 \N
@@ -78,7 +78,7 @@
 \N
 
 -- !sql_double_5 --
-5.488775193742423
+5.488775193742424
 
 -- !sql_double_6 --
 10
@@ -112,3 +112,18 @@
 \N
 \N
 
+-- !sql_string_1 --
+\N
+
+-- !sql_string_2 --
+\N
+
+-- !sql_bool_1 --
+\N
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git a/regression-test/data/query_p0/aggregate/test_regr_r2.out 
b/regression-test/data/query_p0/aggregate/test_regr_r2.out
new file mode 100644
index 00000000000..e03720a9caa
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/test_regr_r2.out
@@ -0,0 +1,65 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql_empty_1 --
+\N
+
+-- !sql_empty_2 --
+
+-- !sql_int_1 --
+1      1
+2      1
+3      \N
+4      1
+5      \N
+
+-- !sql_int_2 --
+1
+
+-- !sql_int_3 --
+1
+
+-- !sql_int_4 --
+\N
+
+-- !sql_int_5 --
+\N
+
+-- !sql_int_6 --
+\N
+
+-- !sql_double_1 --
+1      1
+2      1
+3      \N
+4      1
+5      \N
+
+-- !sql_double_2 --
+1
+
+-- !sql_double_3 --
+1
+
+-- !sql_double_4 --
+\N
+
+-- !sql_double_5 --
+\N
+
+-- !sql_double_6 --
+\N
+
+-- !sql_string_1 --
+\N
+
+-- !sql_string_2 --
+\N
+
+-- !sql_bool_1 --
+\N
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git a/regression-test/data/query_p0/aggregate/test_regr_slope.out 
b/regression-test/data/query_p0/aggregate/test_regr_slope.out
index 4f8bb74e7be..5900d2fec9e 100644
--- a/regression-test/data/query_p0/aggregate/test_regr_slope.out
+++ b/regression-test/data/query_p0/aggregate/test_regr_slope.out
@@ -17,7 +17,7 @@
 0.6853448275862066
 
 -- !sql_int_5 --
-0.6853448275862066
+0.685344827586207
 
 -- !sql_int_6 --
 0
@@ -58,7 +58,7 @@
 \N
 
 -- !sql_double_3 --
-0.6987176230207438
+0.6987176230207439
 
 -- !sql_double_3 --
 \N
@@ -68,7 +68,7 @@
 \N
 
 -- !sql_double_4 --
-0.6987176230207439
+0.6987176230207438
 
 -- !sql_double_4 --
 \N
@@ -78,7 +78,7 @@
 \N
 
 -- !sql_double_5 --
-0.6987176230207439
+0.6987176230207438
 
 -- !sql_double_6 --
 0
@@ -87,7 +87,7 @@
 \N
 
 -- !sql_double_8 --
-0.7390029325513198
+0.7390029325513199
 
 -- !sql_double_8 --
 \N
@@ -112,3 +112,18 @@
 \N
 \N
 
+-- !sql_string_1 --
+\N
+
+-- !sql_string_2 --
+\N
+
+-- !sql_bool_1 --
+\N
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git 
a/regression-test/data/nereids_function_p0/agg_function/test_regr_sxx.out 
b/regression-test/data/query_p0/aggregate/test_regr_sxx.out
similarity index 75%
rename from 
regression-test/data/nereids_function_p0/agg_function/test_regr_sxx.out
rename to regression-test/data/query_p0/aggregate/test_regr_sxx.out
index 16b597e377d..8aa52332548 100644
--- a/regression-test/data/nereids_function_p0/agg_function/test_regr_sxx.out
+++ b/regression-test/data/query_p0/aggregate/test_regr_sxx.out
@@ -32,3 +32,18 @@
 -- !literal_3 --
 0
 
+-- !sql_string_1 --
+0
+
+-- !sql_string_2 --
+0
+
+-- !sql_bool_1 --
+0
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git 
a/regression-test/data/nereids_function_p0/agg_function/test_regr_sxy.out 
b/regression-test/data/query_p0/aggregate/test_regr_sxy.out
similarity index 75%
rename from 
regression-test/data/nereids_function_p0/agg_function/test_regr_sxy.out
rename to regression-test/data/query_p0/aggregate/test_regr_sxy.out
index a04a5f92675..6653f48ee0d 100644
--- a/regression-test/data/nereids_function_p0/agg_function/test_regr_sxy.out
+++ b/regression-test/data/query_p0/aggregate/test_regr_sxy.out
@@ -32,3 +32,18 @@
 -- !literal_3 --
 0
 
+-- !sql_string_1 --
+0
+
+-- !sql_string_2 --
+0
+
+-- !sql_bool_1 --
+0
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git 
a/regression-test/data/nereids_function_p0/agg_function/test_regr_syy.out 
b/regression-test/data/query_p0/aggregate/test_regr_syy.out
similarity index 75%
rename from 
regression-test/data/nereids_function_p0/agg_function/test_regr_syy.out
rename to regression-test/data/query_p0/aggregate/test_regr_syy.out
index 0754264d911..72f7110e749 100644
--- a/regression-test/data/nereids_function_p0/agg_function/test_regr_syy.out
+++ b/regression-test/data/query_p0/aggregate/test_regr_syy.out
@@ -32,3 +32,18 @@
 -- !literal_3 --
 8
 
+-- !sql_string_1 --
+0
+
+-- !sql_string_2 --
+0
+
+-- !sql_bool_1 --
+0
+
+-- !sql_null_1 --
+\N
+
+-- !sql_null_2 --
+\N
+
diff --git a/regression-test/suites/query_p0/aggregate/test_regr_avgx.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_avgx.groovy
new file mode 100644
index 00000000000..94b2d561e28
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/test_regr_avgx.groovy
@@ -0,0 +1,174 @@
+// 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_regr_avgx") {
+    sql """ DROP TABLE IF EXISTS test_regr_avgx_int """
+    sql """ DROP TABLE IF EXISTS test_regr_avgx_double """
+
+    sql """ SET enable_nereids_planner=true """
+    sql """ SET enable_fallback_to_original_planner=false """
+
+    sql """
+        CREATE TABLE test_regr_avgx_int (
+            id INT,
+            x INT,
+            y INT
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    sql """
+        CREATE TABLE test_regr_avgx_double (
+            id INT,
+            x DOUBLE,
+            y DOUBLE
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    // Empty table: verify NULL
+    qt_sql_empty_1 "select regr_avgx(y, x) from test_regr_avgx_int"
+
+    // Empty table with group by: verify empty result
+    qt_sql_empty_2 "select regr_avgx(y, x) from test_regr_avgx_int group by id"
+
+    // Base dataset (int)
+    sql """
+        INSERT INTO test_regr_avgx_int VALUES
+            -- id=1: one row
+            (1, 10, 20),
+
+            -- id=2: multiple rows
+            (2, 1, 2),
+            (2, 2, 4),
+            (2, 3, 6),
+
+            -- id=3: contains NULL, will be filtered out
+            (3, 1, NULL),
+            (3, NULL, 2),
+            (3, 2, 5),
+            (3, 3, 7),
+
+            -- id=4: all rows contain NULL, regr_avgx should be NULL
+            (4, NULL, 1),
+            (4, 2, NULL),
+
+            -- id=5: constant x
+            (5, 5, 1),
+            (5, 5, 2),
+            (5, 5, 3);
+    """
+
+    // Base dataset (double)
+    sql """
+        INSERT INTO test_regr_avgx_double VALUES
+            -- id=1: one row
+            (1, 10.5, 20.5),
+
+            -- id=2: multiple rows
+            (2, 1.1, 2.1),
+            (2, 2.2, 4.2),
+            (2, 3.3, 6.3),
+
+            -- id=3: contains NULL, will be filtered out
+            (3, 1.1, NULL),
+            (3, NULL, 2.2),
+            (3, 2.2, 5.2),
+            (3, 3.3, 7.2),
+
+            -- id=4: all rows contain NULL, regr_avgx should be NULL
+            (4, NULL, 1.1),
+            (4, 2.2, NULL),
+
+            -- id=5: constant x
+            (5, 5.5, 1.1),
+            (5, 5.5, 2.2),
+            (5, 5.5, 3.3);
+    """
+
+    // Integer inputs
+    qt_sql_int_1 "select regr_avgx(y, x) from test_regr_avgx_int"
+
+    // AVGX(x) = avg(x) over rows where both x and y are non-NULL
+    qt_sql_int_2 """
+        select id, regr_avgx(y, x), avg(x)
+        from test_regr_avgx_int
+        where x is not null and y is not null
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_int_3 "select regr_avgx(non_nullable(y), non_nullable(x)) from 
test_regr_avgx_int where id = 2"
+
+    // Literal
+    qt_sql_int_4 "select regr_avgx(10, x) from test_regr_avgx_int where id = 2"
+    qt_sql_int_5 "select regr_avgx(y, 3) from test_regr_avgx_int where id = 2"
+
+    // All rows invalid (no valid x/y pairs): verify NULL
+    qt_sql_int_6 "select regr_avgx(y, x) from test_regr_avgx_int where id = 4"
+
+    // Double inputs
+    qt_sql_double_1 "select regr_avgx(y, x) from test_regr_avgx_double"
+
+    // AVGX(x) = avg(x) over rows where both x and y are non-NULL
+    qt_sql_double_2 """
+        select id, regr_avgx(y, x), avg(x)
+        from test_regr_avgx_double
+        where x is not null and y is not null
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_double_3 "select regr_avgx(non_nullable(y), non_nullable(x)) from 
test_regr_avgx_double where id = 2"
+
+    // Literal
+    qt_sql_double_4 "select regr_avgx(10, x) from test_regr_avgx_double where 
id = 2"
+    qt_sql_double_5 "select regr_avgx(y, 3) from test_regr_avgx_double where 
id = 2"
+
+    // All rows invalid (no valid x/y pairs): verify NULL
+    qt_sql_double_6 "select regr_avgx(y, x) from test_regr_avgx_double where 
id = 4"
+
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_avgx('5', '3')"
+    qt_sql_string_2 "select regr_avgx(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_avgx(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_avgx(NULL, 1)"
+    qt_sql_null_2 "select regr_avgx(1, NULL)"
+
+    // Exception inputs
+    test {
+        sql """select regr_avgx(cast([1, 2, 3] as array<int>), 1);"""
+        exception "Can not find the compatibility function signature: 
regr_avgx("
+    }
+    test {
+        sql """select regr_avgx(1, cast([1, 2, 3] as array<int>));"""
+        exception "Can not find the compatibility function signature: 
regr_avgx("
+    }
+}
diff --git a/regression-test/suites/query_p0/aggregate/test_regr_avgy.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_avgy.groovy
new file mode 100644
index 00000000000..c0b76de98cd
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/test_regr_avgy.groovy
@@ -0,0 +1,174 @@
+// 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_regr_avgy") {
+    sql """ DROP TABLE IF EXISTS test_regr_avgy_int """
+    sql """ DROP TABLE IF EXISTS test_regr_avgy_double """
+
+    sql """ SET enable_nereids_planner=true """
+    sql """ SET enable_fallback_to_original_planner=false """
+
+    sql """
+        CREATE TABLE test_regr_avgy_int (
+            id INT,
+            x INT,
+            y INT
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    sql """
+        CREATE TABLE test_regr_avgy_double (
+            id INT,
+            x DOUBLE,
+            y DOUBLE
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    // Empty table: verify NULL
+    qt_sql_empty_1 "select regr_avgy(y, x) from test_regr_avgy_int"
+
+    // Empty table with group by: verify empty result
+    qt_sql_empty_2 "select regr_avgy(y, x) from test_regr_avgy_int group by id"
+
+    // Base dataset (int)
+    sql """
+        INSERT INTO test_regr_avgy_int VALUES
+            -- id=1: one row
+            (1, 10, 20),
+
+            -- id=2: multiple rows
+            (2, 1, 2),
+            (2, 2, 4),
+            (2, 3, 6),
+
+            -- id=3: contains NULL, will be filtered out
+            (3, 1, NULL),
+            (3, NULL, 2),
+            (3, 2, 5),
+            (3, 3, 7),
+
+            -- id=4: all rows contain NULL, regr_avgy should be NULL
+            (4, NULL, 1),
+            (4, 2, NULL),
+
+            -- id=5: constant x
+            (5, 5, 1),
+            (5, 5, 2),
+            (5, 5, 3);
+    """
+
+    // Base dataset (double)
+    sql """
+        INSERT INTO test_regr_avgy_double VALUES
+            -- id=1: one row
+            (1, 10.5, 20.5),
+
+            -- id=2: multiple rows
+            (2, 1.1, 2.1),
+            (2, 2.2, 4.2),
+            (2, 3.3, 6.3),
+
+            -- id=3: contains NULL, will be filtered out
+            (3, 1.1, NULL),
+            (3, NULL, 2.2),
+            (3, 2.2, 5.2),
+            (3, 3.3, 7.2),
+
+            -- id=4: all rows contain NULL, regr_avgy should be NULL
+            (4, NULL, 1.1),
+            (4, 2.2, NULL),
+
+            -- id=5: constant x
+            (5, 5.5, 1.1),
+            (5, 5.5, 2.2),
+            (5, 5.5, 3.3);
+    """
+
+    // Integer inputs
+    qt_sql_int_1 "select regr_avgy(y, x) from test_regr_avgy_int"
+
+    // AVGY(y) = avg(y) over rows where both x and y are non-NULL
+    qt_sql_int_2 """
+        select id, regr_avgy(y, x), avg(y)
+        from test_regr_avgy_int
+        where x is not null and y is not null
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_int_3 "select regr_avgy(non_nullable(y), non_nullable(x)) from 
test_regr_avgy_int where id = 2"
+
+    // Literal
+    qt_sql_int_4 "select regr_avgy(10, x) from test_regr_avgy_int where id = 2"
+    qt_sql_int_5 "select regr_avgy(y, 3) from test_regr_avgy_int where id = 2"
+
+    // All rows invalid (no valid x/y pairs): verify NULL
+    qt_sql_int_6 "select regr_avgy(y, x) from test_regr_avgy_int where id = 4"
+
+    // Double inputs
+    qt_sql_double_1 "select regr_avgy(y, x) from test_regr_avgy_double"
+
+    // AVGY(y) = avg(y) over rows where both x and y are non-NULL
+    qt_sql_double_2 """
+        select id, regr_avgy(y, x), avg(y)
+        from test_regr_avgy_double
+        where x is not null and y is not null
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_double_3 "select regr_avgy(non_nullable(y), non_nullable(x)) from 
test_regr_avgy_double where id = 2"
+
+    // Literal
+    qt_sql_double_4 "select regr_avgy(10, x) from test_regr_avgy_double where 
id = 2"
+    qt_sql_double_5 "select regr_avgy(y, 3) from test_regr_avgy_double where 
id = 2"
+
+    // All rows invalid (no valid x/y pairs): verify NULL
+    qt_sql_double_6 "select regr_avgy(y, x) from test_regr_avgy_double where 
id = 4"
+
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_avgy('5', '3')"
+    qt_sql_string_2 "select regr_avgy(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_avgy(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_avgy(NULL, 1)"
+    qt_sql_null_2 "select regr_avgy(1, NULL)"
+
+    // Exception inputs
+    test {
+        sql """select regr_avgy(cast([1, 2, 3] as array<int>), 1);"""
+        exception "Can not find the compatibility function signature: 
regr_avgy("
+    }
+    test {
+        sql """select regr_avgy(1, cast([1, 2, 3] as array<int>));"""
+        exception "Can not find the compatibility function signature: 
regr_avgy("
+    }
+}
diff --git a/regression-test/suites/query_p0/aggregate/test_regr_count.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_count.groovy
new file mode 100644
index 00000000000..9aed8a1c198
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/test_regr_count.groovy
@@ -0,0 +1,174 @@
+// 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_regr_count") {
+    sql """ DROP TABLE IF EXISTS test_regr_count_int """
+    sql """ DROP TABLE IF EXISTS test_regr_count_double """
+
+    sql """ SET enable_nereids_planner=true """
+    sql """ SET enable_fallback_to_original_planner=false """
+
+    sql """
+        CREATE TABLE test_regr_count_int (
+            id INT,
+            x INT,
+            y INT
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    sql """
+        CREATE TABLE test_regr_count_double (
+            id INT,
+            x DOUBLE,
+            y DOUBLE
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    // Empty table: verify 0
+    qt_sql_empty_1 "select regr_count(y, x) from test_regr_count_int"
+
+    // Empty table with group by: verify empty result
+    qt_sql_empty_2 "select regr_count(y, x) from test_regr_count_int group by 
id"
+
+    // Base dataset (int)
+    sql """
+        INSERT INTO test_regr_count_int VALUES
+            -- id=1: one row
+            (1, 10, 20),
+
+            -- id=2: multiple rows
+            (2, 1, 2),
+            (2, 2, 4),
+            (2, 3, 6),
+
+            -- id=3: contains NULL, will be filtered out
+            (3, 1, NULL),
+            (3, NULL, 2),
+            (3, 2, 5),
+            (3, 3, 7),
+
+            -- id=4: all rows contain NULL, regr_count should be 0
+            (4, NULL, 1),
+            (4, 2, NULL),
+
+            -- id=5: constant x
+            (5, 5, 1),
+            (5, 5, 2),
+            (5, 5, 3);
+    """
+
+    // Base dataset (double)
+    sql """
+        INSERT INTO test_regr_count_double VALUES
+            -- id=1: one row
+            (1, 10.5, 20.5),
+
+            -- id=2: multiple rows
+            (2, 1.1, 2.1),
+            (2, 2.2, 4.2),
+            (2, 3.3, 6.3),
+
+            -- id=3: contains NULL, will be filtered out
+            (3, 1.1, NULL),
+            (3, NULL, 2.2),
+            (3, 2.2, 5.2),
+            (3, 3.3, 7.2),
+
+            -- id=4: all rows contain NULL, regr_count should be 0
+            (4, NULL, 1.1),
+            (4, 2.2, NULL),
+
+            -- id=5: constant x
+            (5, 5.5, 1.1),
+            (5, 5.5, 2.2),
+            (5, 5.5, 3.3);
+    """
+
+    // Integer inputs
+    qt_sql_int_1 "select regr_count(y, x) from test_regr_count_int"
+
+    // COUNT(*) over rows where both x and y are non-NULL
+    qt_sql_int_2 """
+        select id, regr_count(y, x), count(*)
+        from test_regr_count_int
+        where x is not null and y is not null
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_int_3 "select regr_count(non_nullable(y), non_nullable(x)) from 
test_regr_count_int where id = 2"
+
+    // Literal
+    qt_sql_int_4 "select regr_count(10, x) from test_regr_count_int where id = 
2"
+    qt_sql_int_5 "select regr_count(y, 3) from test_regr_count_int where id = 
2"
+
+    // All rows invalid (no valid x/y pairs): verify 0
+    qt_sql_int_6 "select regr_count(y, x) from test_regr_count_int where id = 
4"
+
+    // Double inputs
+    qt_sql_double_1 "select regr_count(y, x) from test_regr_count_double"
+
+    // COUNT(*) over rows where both x and y are non-NULL
+    qt_sql_double_2 """
+        select id, regr_count(y, x), count(*)
+        from test_regr_count_double
+        where x is not null and y is not null
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_double_3 "select regr_count(non_nullable(y), non_nullable(x)) from 
test_regr_count_double where id = 2"
+
+    // Literal
+    qt_sql_double_4 "select regr_count(10, x) from test_regr_count_double 
where id = 2"
+    qt_sql_double_5 "select regr_count(y, 3) from test_regr_count_double where 
id = 2"
+
+    // All rows invalid (no valid x/y pairs): verify 0
+    qt_sql_double_6 "select regr_count(y, x) from test_regr_count_double where 
id = 4"
+
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_count('5', '3')"
+    qt_sql_string_2 "select regr_count(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_count(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_count(NULL, 1)"
+    qt_sql_null_2 "select regr_count(1, NULL)"
+
+    // Exception inputs
+    test {
+        sql """select regr_count(cast([1, 2, 3] as array<int>), 1);"""
+        exception "Can not find the compatibility function signature: 
regr_count("
+    }
+    test {
+        sql """select regr_count(1, cast([1, 2, 3] as array<int>));"""
+        exception "Can not find the compatibility function signature: 
regr_count("
+    }
+}
diff --git 
a/regression-test/suites/query_p0/aggregate/test_regr_intercept.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_intercept.groovy
index 19af402e4d8..c7a5ac83af4 100644
--- a/regression-test/suites/query_p0/aggregate/test_regr_intercept.groovy
+++ b/regression-test/suites/query_p0/aggregate/test_regr_intercept.groovy
@@ -191,25 +191,25 @@ suite("test_regr_intercept") {
     qt_sql_double_10 "select regr_intercept(y, non_nullable(x)) from 
test_regr_intercept_double where id >= 3"
     qt_sql_double_10 "select regr_intercept(y, non_nullable(x)) from 
test_regr_intercept_double where id >= 3 group by id order by id"
 
-    // exception test
-    test{
-        sql """select regr_intercept('range', 1);"""
-        exception "regr_intercept requires numeric for first parameter"
-    }
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_intercept('5', '3')"
+    qt_sql_string_2 "select regr_intercept(1, '3')"
 
-    test{
-        sql """select regr_intercept(1, 'hello');"""
-        exception "regr_intercept requires numeric for second parameter"
-    }
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_intercept(true, false)"
 
-    test{
-        sql """select regr_intercept(y, 'hello') from 
test_regr_intercept_int;"""
-        exception "regr_intercept requires numeric for second parameter"
-    }
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_intercept(NULL, 1)"
+    qt_sql_null_2 "select regr_intercept(1, NULL)"
 
-    test{
-        sql """select regr_intercept(1, true);"""
-        exception "regr_intercept requires numeric for second parameter"
+    // Exception inputs
+    test {
+        sql """select regr_intercept(cast([1, 2, 3] as array<int>), 1);"""
+        exception "Can not find the compatibility function signature: 
regr_intercept("
+    }
+    test {
+        sql """select regr_intercept(1, cast([1, 2, 3] as array<int>));"""
+        exception "Can not find the compatibility function signature: 
regr_intercept("
     }
 
 }
diff --git a/regression-test/suites/query_p0/aggregate/test_regr_r2.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_r2.groovy
new file mode 100644
index 00000000000..86fcee290dd
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/test_regr_r2.groovy
@@ -0,0 +1,172 @@
+// 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_regr_r2") {
+    sql """ DROP TABLE IF EXISTS test_regr_r2_int """
+    sql """ DROP TABLE IF EXISTS test_regr_r2_double """
+
+    sql """ SET enable_nereids_planner=true """
+    sql """ SET enable_fallback_to_original_planner=false """
+
+    sql """
+        CREATE TABLE test_regr_r2_int (
+            id INT,
+            x INT,
+            y INT
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    sql """
+        CREATE TABLE test_regr_r2_double (
+            id INT,
+            x DOUBLE,
+            y DOUBLE
+        ) ENGINE=OLAP
+        DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 4
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    // Empty table: verify NULL
+    qt_sql_empty_1 "select regr_r2(y, x) from test_regr_r2_int"
+
+    // Empty table with group by: verify empty result
+    qt_sql_empty_2 "select regr_r2(y, x) from test_regr_r2_int group by id"
+
+    // Base dataset (int)
+    sql """
+        INSERT INTO test_regr_r2_int VALUES
+            -- id=1: perfect linear relation
+            (1, 1, 2),
+            (1, 2, 4),
+            (1, 3, 6),
+
+            -- id=2: horizontal line, return 1.0 per PG
+            (2, 1, 5),
+            (2, 2, 5),
+            (2, 3, 5),
+
+            -- id=3: vertical line, return NULL
+            (3, 5, 1),
+            (3, 5, 2),
+            (3, 5, 3),
+
+            -- id=4: valid rows mixed with NULL
+            (4, 1, NULL),
+            (4, NULL, 2),
+            (4, 2, 4),
+            (4, 3, 6),
+
+            -- id=5: all rows invalid, return NULL
+            (5, NULL, 1),
+            (5, 2, NULL);
+    """
+
+    // Base dataset (double)
+    sql """
+        INSERT INTO test_regr_r2_double VALUES
+            -- id=1: perfect linear relation
+            (1, 1.1, 2.2),
+            (1, 2.2, 4.4),
+            (1, 3.3, 6.6),
+
+            -- id=2: horizontal line, return 1.0 per PG
+            (2, 1.1, 5.5),
+            (2, 2.2, 5.5),
+            (2, 3.3, 5.5),
+
+            -- id=3: vertical line, return NULL
+            (3, 5.5, 1.1),
+            (3, 5.5, 2.2),
+            (3, 5.5, 3.3),
+
+            -- id=4: valid rows mixed with NULL
+            (4, 1.1, NULL),
+            (4, NULL, 2.2),
+            (4, 2.2, 4.4),
+            (4, 3.3, 6.6),
+
+            -- id=5: all rows invalid, return NULL
+            (5, NULL, 1.1),
+            (5, 2.2, NULL);
+    """
+
+    // Integer inputs
+    qt_sql_int_1 """
+        select id, regr_r2(y, x)
+        from test_regr_r2_int
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_int_2 "select regr_r2(non_nullable(y), non_nullable(x)) from 
test_regr_r2_int where id = 1"
+
+    // Literal
+    qt_sql_int_3 "select regr_r2(10, x) from test_regr_r2_int where id = 1"
+    qt_sql_int_4 "select regr_r2(y, 3) from test_regr_r2_int where id = 1"
+
+    // All rows invalid (x constant or no valid x/y pairs): verify NULL
+    qt_sql_int_5 "select regr_r2(y, x) from test_regr_r2_int where id = 3"
+    qt_sql_int_6 "select regr_r2(y, x) from test_regr_r2_int where id = 5"
+
+    // Double inputs
+    qt_sql_double_1 """
+        select id, regr_r2(y, x)
+        from test_regr_r2_double
+        group by id
+        order by id
+    """
+
+    // Mix non_nullable
+    qt_sql_double_2 "select regr_r2(non_nullable(y), non_nullable(x)) from 
test_regr_r2_double where id = 1"
+
+    // Literal
+    qt_sql_double_3 "select regr_r2(10, x) from test_regr_r2_double where id = 
1"
+    qt_sql_double_4 "select regr_r2(y, 3) from test_regr_r2_double where id = 
1"
+
+    // All rows invalid (x constant or no valid x/y pairs): verify NULL
+    qt_sql_double_5 "select regr_r2(y, x) from test_regr_r2_double where id = 
3"
+    qt_sql_double_6 "select regr_r2(y, x) from test_regr_r2_double where id = 
5"
+
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_r2('5', '3')"
+    qt_sql_string_2 "select regr_r2(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_r2(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_r2(NULL, 1)"
+    qt_sql_null_2 "select regr_r2(1, NULL)"
+
+    // Exception inputs
+    test {
+        sql """select regr_r2(cast([1, 2, 3] as array<int>), 1);"""
+        exception "Can not find the compatibility function signature: regr_r2("
+    }
+    test {
+        sql """select regr_r2(1, cast([1, 2, 3] as array<int>));"""
+        exception "Can not find the compatibility function signature: regr_r2("
+    }
+}
diff --git a/regression-test/suites/query_p0/aggregate/test_regr_slope.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_slope.groovy
index db95283ab7f..0910ae9aa79 100644
--- a/regression-test/suites/query_p0/aggregate/test_regr_slope.groovy
+++ b/regression-test/suites/query_p0/aggregate/test_regr_slope.groovy
@@ -191,25 +191,25 @@ suite("test_regr_slope") {
     qt_sql_double_10 "select regr_slope(y, non_nullable(x)) from 
test_regr_slope_double where id >= 3"
     qt_sql_double_10 "select regr_slope(y, non_nullable(x)) from 
test_regr_slope_double where id >= 3 group by id order by id"
 
-    // exception test
-    test{
-        sql """select regr_slope('range', 1);"""
-        exception "regr_slope requires numeric for first parameter"
-    }
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_slope('5', '3')"
+    qt_sql_string_2 "select regr_slope(1, '3')"
 
-    test{
-        sql """select regr_slope(1, 'hello');"""
-        exception "regr_slope requires numeric for second parameter"
-    }
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_slope(true, false)"
 
-    test{
-        sql """select regr_slope(y, 'hello') from test_regr_slope_int;"""
-        exception "regr_slope requires numeric for second parameter"
-    }
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_slope(NULL, 1)"
+    qt_sql_null_2 "select regr_slope(1, NULL)"
 
-    test{
-        sql """select regr_slope(1, true);"""
-        exception "regr_slope requires numeric for second parameter"
+    // Exception inputs
+    test {
+        sql """select regr_slope(cast([1, 2, 3] as array<int>), 1);"""
+        exception "Can not find the compatibility function signature: 
regr_slope("
+    }
+    test {
+        sql """select regr_slope(1, cast([1, 2, 3] as array<int>));"""
+        exception "Can not find the compatibility function signature: 
regr_slope("
     }
 
 }
diff --git 
a/regression-test/suites/nereids_function_p0/agg_function/test_regr_sxx.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_sxx.groovy
similarity index 83%
rename from 
regression-test/suites/nereids_function_p0/agg_function/test_regr_sxx.groovy
rename to regression-test/suites/query_p0/aggregate/test_regr_sxx.groovy
index 3e9b0a388e4..b0bc23660ce 100644
--- 
a/regression-test/suites/nereids_function_p0/agg_function/test_regr_sxx.groovy
+++ b/regression-test/suites/query_p0/aggregate/test_regr_sxx.groovy
@@ -91,17 +91,24 @@ suite("test_regr_sxx") {
     qt_literal_2 "SELECT regr_sxx(10, x) FROM test_regr_sxx WHERE id = 2"
     qt_literal_3 "SELECT regr_sxx(y, 3) FROM test_regr_sxx WHERE id = 2"
 
-    // exception
-    test {
-        sql "select regr_sxx('y', 1)"
-        exception "regr_sxx requires numeric for first parameter"
-    }
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_sxx('5', '3')"
+    qt_sql_string_2 "select regr_sxx(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_sxx(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_sxx(NULL, 1)"
+    qt_sql_null_2 "select regr_sxx(1, NULL)"
+
+    // Exception inputs
     test {
-        sql "select regr_sxx(1, 'x')"
-        exception "regr_sxx requires numeric for second parameter"
+        sql "select regr_sxx(CAST([1, 2, 3] AS ARRAY<INT>), 1)"
+        exception "Can not find the compatibility function signature: 
regr_sxx("
     }
     test {
         sql "select regr_sxx(1, CAST([1, 2, 3] AS ARRAY<INT>))"
-        exception "Doris hll, bitmap, array, map, struct, jsonb, variant 
column"
+        exception "Can not find the compatibility function signature: 
regr_sxx("
     }
 }
diff --git 
a/regression-test/suites/nereids_function_p0/agg_function/test_regr_sxy.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_sxy.groovy
similarity index 83%
rename from 
regression-test/suites/nereids_function_p0/agg_function/test_regr_sxy.groovy
rename to regression-test/suites/query_p0/aggregate/test_regr_sxy.groovy
index a657cdb27f5..d6722bd21a1 100644
--- 
a/regression-test/suites/nereids_function_p0/agg_function/test_regr_sxy.groovy
+++ b/regression-test/suites/query_p0/aggregate/test_regr_sxy.groovy
@@ -90,17 +90,24 @@ suite("test_regr_sxy") {
     qt_literal_2 "SELECT regr_sxy(10, x) FROM test_regr_sxy WHERE id = 2"
     qt_literal_3 "SELECT regr_sxy(y, 3) FROM test_regr_sxy WHERE id = 2"
 
-    // exception
-    test {
-        sql "select regr_sxy('y', 1)"
-        exception "regr_sxy requires numeric for first parameter"
-    }
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_sxy('5', '3')"
+    qt_sql_string_2 "select regr_sxy(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_sxy(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_sxy(NULL, 1)"
+    qt_sql_null_2 "select regr_sxy(1, NULL)"
+
+    // Exception inputs
     test {
-        sql "select regr_sxy(1, 'x')"
-        exception "regr_sxy requires numeric for second parameter"
+        sql "select regr_sxy(CAST([1, 2, 3] AS ARRAY<INT>), 1)"
+        exception "Can not find the compatibility function signature: 
regr_sxy("
     }
     test {
         sql "select regr_sxy(1, CAST([1, 2, 3] AS ARRAY<INT>))"
-        exception "Doris hll, bitmap, array, map, struct, jsonb, variant 
column"
+        exception "Can not find the compatibility function signature: 
regr_sxy("
     }
-}
\ No newline at end of file
+}
diff --git 
a/regression-test/suites/nereids_function_p0/agg_function/test_regr_syy.groovy 
b/regression-test/suites/query_p0/aggregate/test_regr_syy.groovy
similarity index 83%
rename from 
regression-test/suites/nereids_function_p0/agg_function/test_regr_syy.groovy
rename to regression-test/suites/query_p0/aggregate/test_regr_syy.groovy
index a01b44810b4..97518505f0c 100644
--- 
a/regression-test/suites/nereids_function_p0/agg_function/test_regr_syy.groovy
+++ b/regression-test/suites/query_p0/aggregate/test_regr_syy.groovy
@@ -91,17 +91,24 @@ suite("test_regr_syy") {
     qt_literal_2 "SELECT regr_syy(10, x) FROM test_regr_syy WHERE id = 2"
     qt_literal_3 "SELECT regr_syy(y, 3) FROM test_regr_syy WHERE id = 2"
 
-    // exception
-    test {
-        sql "select regr_syy('y', 1)"
-        exception "regr_syy requires numeric for first parameter"
-    }
+    // String type inputs (compile-time cast only, no table needed)
+    qt_sql_string_1 "select regr_syy('5', '3')"
+    qt_sql_string_2 "select regr_syy(1, '3')"
+
+    // Boolean type inputs
+    qt_sql_bool_1 "select regr_syy(true, false)"
+
+    // NULL literal inputs
+    qt_sql_null_1 "select regr_syy(NULL, 1)"
+    qt_sql_null_2 "select regr_syy(1, NULL)"
+
+    // Exception inputs
     test {
-        sql "select regr_syy(1, 'x')"
-        exception "regr_syy requires numeric for second parameter"
+        sql "select regr_syy(CAST([1, 2, 3] AS ARRAY<INT>), 1)"
+        exception "Can not find the compatibility function signature: 
regr_syy("
     }
     test {
         sql "select regr_syy(1, CAST([1, 2, 3] AS ARRAY<INT>))"
-        exception "Doris hll, bitmap, array, map, struct, jsonb, variant 
column"
+        exception "Can not find the compatibility function signature: 
regr_syy("
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to