JoverZhang commented on code in PR #61352: URL: https://github.com/apache/doris/pull/61352#discussion_r2937492469
########## be/src/exprs/aggregate/aggregate_function_regr.h: ########## @@ -0,0 +1,536 @@ +// 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 { +#include "common/compile_check_begin.h" + +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; Review Comment: Older versions used `2` here. It might be possible to reduce this to `1`, but doing so could change the serialized aggregate-state layout and potentially break `deserialize()` compatibility. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
