From 9d071b2156a0c5666a7a1409142bdb7943f61e00 Mon Sep 17 00:00:00 2001 From: BiteTheDDDDt Date: Sun, 29 Sep 2024 16:10:47 +0800 Subject: [PATCH] update --- .../aggregate_function_covar.cpp | 16 +- .../aggregate_function_covar.h | 34 --- .../aggregate_function_percentile.cpp | 62 +--- .../aggregate_function_percentile.h | 270 ------------------ .../aggregate_function_percentile_approx.cpp | 39 --- .../aggregate_function_percentile_approx.h | 258 ----------------- .../aggregate_function_stddev.cpp | 32 +-- .../aggregate_function_stddev.h | 34 --- .../vec_window_funnel_test.cpp | 3 +- 9 files changed, 11 insertions(+), 737 deletions(-) delete mode 100644 be/src/vec/aggregate_functions/aggregate_function_percentile_approx.cpp delete mode 100644 be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h diff --git a/be/src/vec/aggregate_functions/aggregate_function_covar.cpp b/be/src/vec/aggregate_functions/aggregate_function_covar.cpp index 76a2881dd78280..b02d6ae0e12572 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_covar.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_covar.cpp @@ -51,15 +51,6 @@ AggregateFunctionPtr create_function_single_value(const String& name, return nullptr; } -template -AggregateFunctionPtr create_aggregate_function_covariance_samp_old(const std::string& name, - const DataTypes& argument_types, - const bool result_is_nullable) { - return create_function_single_value(name, argument_types, result_is_nullable, - NULLABLE); -} - AggregateFunctionPtr create_aggregate_function_covariance_samp(const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { @@ -80,12 +71,7 @@ void register_aggregate_function_covar_pop(AggregateFunctionSimpleFactory& facto } void register_aggregate_function_covar_samp_old(AggregateFunctionSimpleFactory& factory) { - factory.register_alternative_function( - "covar_samp", create_aggregate_function_covariance_samp_old, false, - AGG_FUNCTION_NULLABLE); - factory.register_alternative_function("covar_samp", - create_aggregate_function_covariance_samp_old, - true, AGG_FUNCTION_NULLABLE); + BeExecVersionManager::registe_restrict_function_compatibility("covar_samp"); } void register_aggregate_function_covar_samp(AggregateFunctionSimpleFactory& factory) { diff --git a/be/src/vec/aggregate_functions/aggregate_function_covar.h b/be/src/vec/aggregate_functions/aggregate_function_covar.h index 78a3eae5bcb4e9..e6ebec70285d72 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_covar.h +++ b/be/src/vec/aggregate_functions/aggregate_function_covar.h @@ -137,32 +137,6 @@ struct PopData : Data { static DataTypePtr get_return_type() { return std::make_shared>(); } }; -template -struct SampData_OLDER : Data { - void insert_result_into(IColumn& to) const { - if (to.is_nullable()) { - ColumnNullable& nullable_column = assert_cast(to); - if (this->count == 1 || this->count == 0) { - nullable_column.insert_default(); - } else { - auto& col = assert_cast(nullable_column.get_nested_column()); - col.get_data().push_back(this->get_samp_result()); - nullable_column.get_null_map_data().push_back(0); - } - } else { - auto& col = assert_cast(to); - if (this->count == 1 || this->count == 0) { - col.insert_default(); - } else { - col.get_data().push_back(this->get_samp_result()); - } - } - } - static DataTypePtr get_return_type() { - return make_nullable(std::make_shared>()); - } -}; - template struct SampData : Data { void insert_result_into(IColumn& to) const { @@ -258,14 +232,6 @@ class AggregateFunctionSampCovariance } }; -template -class AggregateFunctionSamp_OLDER final - : public AggregateFunctionSampCovariance { -public: - AggregateFunctionSamp_OLDER(const DataTypes& argument_types_) - : AggregateFunctionSampCovariance(argument_types_) {} -}; - template class AggregateFunctionSamp final : public AggregateFunctionSampCovariance { diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp b/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp index ac8e40d03124d6..248d808f2cc67c 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_percentile.cpp @@ -23,27 +23,6 @@ namespace doris::vectorized { -template -AggregateFunctionPtr create_aggregate_function_percentile_approx_older( - const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { - const DataTypePtr& argument_type = remove_nullable(argument_types[0]); - WhichDataType which(argument_type); - if (which.idx != TypeIndex::Float64) { - return nullptr; - } - if (argument_types.size() == 2) { - return creator_without_type::create< - AggregateFunctionPercentileApproxTwoParams_OLDER>( - remove_nullable(argument_types), result_is_nullable); - } - if (argument_types.size() == 3) { - return creator_without_type::create< - AggregateFunctionPercentileApproxThreeParams_OLDER>( - remove_nullable(argument_types), result_is_nullable); - } - return nullptr; -} - AggregateFunctionPtr create_aggregate_function_percentile_approx(const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { @@ -63,27 +42,6 @@ AggregateFunctionPtr create_aggregate_function_percentile_approx(const std::stri return nullptr; } -template -AggregateFunctionPtr create_aggregate_function_percentile_approx_weighted_older( - const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { - const DataTypePtr& argument_type = remove_nullable(argument_types[0]); - WhichDataType which(argument_type); - if (which.idx != TypeIndex::Float64) { - return nullptr; - } - if (argument_types.size() == 3) { - return creator_without_type::create< - AggregateFunctionPercentileApproxWeightedThreeParams_OLDER>( - remove_nullable(argument_types), result_is_nullable); - } - if (argument_types.size() == 4) { - return creator_without_type::create< - AggregateFunctionPercentileApproxWeightedFourParams_OLDER>( - remove_nullable(argument_types), result_is_nullable); - } - return nullptr; -} - AggregateFunctionPtr create_aggregate_function_percentile_approx_weighted( const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { const DataTypePtr& argument_type = remove_nullable(argument_types[0]); @@ -111,20 +69,12 @@ void register_aggregate_function_percentile(AggregateFunctionSimpleFactory& fact } void register_percentile_approx_old_function(AggregateFunctionSimpleFactory& factory) { - factory.register_alternative_function("percentile_approx", - create_aggregate_function_percentile_approx_older, - false, AGG_FUNCTION_NULLABLE); - factory.register_alternative_function("percentile_approx", - create_aggregate_function_percentile_approx_older, - true, AGG_FUNCTION_NULLABLE); - factory.register_alternative_function( - "percentile_approx_weighted", - create_aggregate_function_percentile_approx_weighted_older, false, - AGG_FUNCTION_NULLABLE); - factory.register_alternative_function( - "percentile_approx_weighted", - create_aggregate_function_percentile_approx_weighted_older, true, - AGG_FUNCTION_NULLABLE); + BeExecVersionManager::registe_restrict_function_compatibility("percentile_approx"); + BeExecVersionManager::registe_restrict_function_compatibility("percentile_approx_weighted"); +} + +void register_aggregate_function_percentile_old(AggregateFunctionSimpleFactory& factory) { + BeExecVersionManager::registe_restrict_function_compatibility("percentile"); } void register_aggregate_function_percentile_approx(AggregateFunctionSimpleFactory& factory) { diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile.h b/be/src/vec/aggregate_functions/aggregate_function_percentile.h index 0cec238846eba1..a1e739d8758fa7 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_percentile.h +++ b/be/src/vec/aggregate_functions/aggregate_function_percentile.h @@ -182,68 +182,6 @@ class AggregateFunctionPercentileApprox } }; -template -class AggregateFunctionPercentileApproxTwoParams_OLDER : public AggregateFunctionPercentileApprox { -public: - AggregateFunctionPercentileApproxTwoParams_OLDER(const DataTypes& argument_types_) - : AggregateFunctionPercentileApprox(argument_types_) {} - void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num, - Arena*) const override { - if constexpr (is_nullable) { - double column_data[2] = {0, 0}; - - for (int i = 0; i < 2; ++i) { - const auto* nullable_column = check_and_get_column(columns[i]); - if (nullable_column == nullptr) { //Not Nullable column - const auto& column = - assert_cast( - *columns[i]); - column_data[i] = column.get_element(row_num); - } else if (!nullable_column->is_null_at( - row_num)) { // Nullable column && Not null data - const auto& column = - assert_cast( - nullable_column->get_nested_column()); - column_data[i] = column.get_element(row_num); - } else { // Nullable column && null data - if (i == 0) { - return; - } - } - } - - this->data(place).init(); - this->data(place).add(column_data[0], column_data[1]); - - } else { - const auto& sources = - assert_cast(*columns[0]); - const auto& quantile = - assert_cast(*columns[1]); - - this->data(place).init(); - this->data(place).add(sources.get_element(row_num), quantile.get_element(row_num)); - } - } - - DataTypePtr get_return_type() const override { - return make_nullable(std::make_shared()); - } - - void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { - auto& nullable_column = assert_cast(to); - double result = AggregateFunctionPercentileApprox::data(place).get(); - - if (std::isnan(result)) { - nullable_column.insert_default(); - } else { - auto& col = assert_cast(nullable_column.get_nested_column()); - col.get_data().push_back(result); - nullable_column.get_null_map_data().push_back(0); - } - } -}; - class AggregateFunctionPercentileApproxTwoParams : public AggregateFunctionPercentileApprox { public: AggregateFunctionPercentileApproxTwoParams(const DataTypes& argument_types_) @@ -272,71 +210,6 @@ class AggregateFunctionPercentileApproxTwoParams : public AggregateFunctionPerce } }; -template -class AggregateFunctionPercentileApproxThreeParams_OLDER - : public AggregateFunctionPercentileApprox { -public: - AggregateFunctionPercentileApproxThreeParams_OLDER(const DataTypes& argument_types_) - : AggregateFunctionPercentileApprox(argument_types_) {} - void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num, - Arena*) const override { - if constexpr (is_nullable) { - double column_data[3] = {0, 0, 0}; - - for (int i = 0; i < 3; ++i) { - const auto* nullable_column = check_and_get_column(columns[i]); - if (nullable_column == nullptr) { //Not Nullable column - const auto& column = - assert_cast( - *columns[i]); - column_data[i] = column.get_element(row_num); - } else if (!nullable_column->is_null_at( - row_num)) { // Nullable column && Not null data - const auto& column = - assert_cast( - nullable_column->get_nested_column()); - column_data[i] = column.get_element(row_num); - } else { // Nullable column && null data - if (i == 0) { - return; - } - } - } - - this->data(place).init(column_data[2]); - this->data(place).add(column_data[0], column_data[1]); - - } else { - const auto& sources = - assert_cast(*columns[0]); - const auto& quantile = - assert_cast(*columns[1]); - const auto& compression = - assert_cast(*columns[2]); - - this->data(place).init(compression.get_element(row_num)); - this->data(place).add(sources.get_element(row_num), quantile.get_element(row_num)); - } - } - - DataTypePtr get_return_type() const override { - return make_nullable(std::make_shared()); - } - - void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { - auto& nullable_column = assert_cast(to); - double result = AggregateFunctionPercentileApprox::data(place).get(); - - if (std::isnan(result)) { - nullable_column.insert_default(); - } else { - auto& col = assert_cast(nullable_column.get_nested_column()); - col.get_data().push_back(result); - nullable_column.get_null_map_data().push_back(0); - } - } -}; - class AggregateFunctionPercentileApproxThreeParams : public AggregateFunctionPercentileApprox { public: AggregateFunctionPercentileApproxThreeParams(const DataTypes& argument_types_) @@ -368,76 +241,6 @@ class AggregateFunctionPercentileApproxThreeParams : public AggregateFunctionPer } }; -template -class AggregateFunctionPercentileApproxWeightedThreeParams_OLDER - : public AggregateFunctionPercentileApprox { -public: - AggregateFunctionPercentileApproxWeightedThreeParams_OLDER(const DataTypes& argument_types_) - : AggregateFunctionPercentileApprox(argument_types_) {} - - void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num, - Arena*) const override { - if constexpr (is_nullable) { - // sources quantile weight - double column_data[3] = {0, 0, 0}; - for (int i = 0; i < 3; ++i) { - const auto* nullable_column = check_and_get_column(columns[i]); - if (nullable_column == nullptr) { //Not Nullable column - const auto& column = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[i]); - column_data[i] = column.get_element(row_num); - } else if (!nullable_column->is_null_at( - row_num)) { // Nullable column && Not null data - const auto& column = - assert_cast&, TypeCheckOnRelease::DISABLE>( - nullable_column->get_nested_column()); - column_data[i] = column.get_element(row_num); - } else { // Nullable column && null data - if (i == 0) { - return; - } - } - } - this->data(place).init(); - this->data(place).add_with_weight(column_data[0], column_data[1], column_data[2]); - - } else { - const auto& sources = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[0]); - const auto& weight = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[1]); - const auto& quantile = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[2]); - - this->data(place).init(); - this->data(place).add_with_weight(sources.get_element(row_num), - weight.get_element(row_num), - quantile.get_element(row_num)); - } - } - - DataTypePtr get_return_type() const override { - return make_nullable(std::make_shared()); - } - - void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { - auto& nullable_column = assert_cast(to); - double result = AggregateFunctionPercentileApprox::data(place).get(); - - if (std::isnan(result)) { - nullable_column.insert_default(); - } else { - auto& col = assert_cast(nullable_column.get_nested_column()); - col.get_data().push_back(result); - nullable_column.get_null_map_data().push_back(0); - } - } -}; - class AggregateFunctionPercentileApproxWeightedThreeParams : public AggregateFunctionPercentileApprox { public: @@ -472,79 +275,6 @@ class AggregateFunctionPercentileApproxWeightedThreeParams } }; -template -class AggregateFunctionPercentileApproxWeightedFourParams_OLDER - : public AggregateFunctionPercentileApprox { -public: - AggregateFunctionPercentileApproxWeightedFourParams_OLDER(const DataTypes& argument_types_) - : AggregateFunctionPercentileApprox(argument_types_) {} - void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num, - Arena*) const override { - if constexpr (is_nullable) { - double column_data[4] = {0, 0, 0, 0}; - - for (int i = 0; i < 4; ++i) { - const auto* nullable_column = check_and_get_column(columns[i]); - if (nullable_column == nullptr) { //Not Nullable column - const auto& column = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[i]); - column_data[i] = column.get_element(row_num); - } else if (!nullable_column->is_null_at( - row_num)) { // Nullable column && Not null data - const auto& column = - assert_cast&, TypeCheckOnRelease::DISABLE>( - nullable_column->get_nested_column()); - column_data[i] = column.get_element(row_num); - } else { // Nullable column && null data - if (i == 0) { - return; - } - } - } - - this->data(place).init(column_data[3]); - this->data(place).add_with_weight(column_data[0], column_data[1], column_data[2]); - - } else { - const auto& sources = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[0]); - const auto& weight = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[1]); - const auto& quantile = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[2]); - const auto& compression = - assert_cast&, TypeCheckOnRelease::DISABLE>( - *columns[3]); - - this->data(place).init(compression.get_element(row_num)); - this->data(place).add_with_weight(sources.get_element(row_num), - weight.get_element(row_num), - quantile.get_element(row_num)); - } - } - - DataTypePtr get_return_type() const override { - return make_nullable(std::make_shared()); - } - - void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { - auto& nullable_column = assert_cast(to); - double result = AggregateFunctionPercentileApprox::data(place).get(); - - if (std::isnan(result)) { - nullable_column.insert_default(); - } else { - auto& col = assert_cast(nullable_column.get_nested_column()); - col.get_data().push_back(result); - nullable_column.get_null_map_data().push_back(0); - } - } -}; - class AggregateFunctionPercentileApproxWeightedFourParams : public AggregateFunctionPercentileApprox { public: diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.cpp b/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.cpp deleted file mode 100644 index 5ad1ea8f2d3d70..00000000000000 --- a/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.cpp +++ /dev/null @@ -1,39 +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 "vec/aggregate_functions/aggregate_function_percentile_approx.h" - -#include "vec/aggregate_functions/aggregate_function_simple_factory.h" -#include "vec/aggregate_functions/helpers.h" - -namespace doris::vectorized { - -void register_aggregate_function_percentile_old(AggregateFunctionSimpleFactory& factory) { - factory.register_alternative_function( - "percentile", creator_without_type::creator, false, - AGG_FUNCTION_NULLABLE); - factory.register_alternative_function( - "percentile", creator_without_type::creator, true, - AGG_FUNCTION_NULLABLE); - factory.register_alternative_function( - "percentile_array", creator_without_type::creator, - false, AGG_FUNCTION_NULLABLE); - factory.register_alternative_function( - "percentile_array", creator_without_type::creator, - true, AGG_FUNCTION_NULLABLE); -} -} // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h b/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h deleted file mode 100644 index 8698355897d2cb..00000000000000 --- a/be/src/vec/aggregate_functions/aggregate_function_percentile_approx.h +++ /dev/null @@ -1,258 +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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "util/counts.h" -#include "util/tdigest.h" -#include "vec/aggregate_functions/aggregate_function.h" -#include "vec/columns/column.h" -#include "vec/columns/column_array.h" -#include "vec/columns/column_nullable.h" -#include "vec/columns/column_vector.h" -#include "vec/common/assert_cast.h" -#include "vec/common/pod_array_fwd.h" -#include "vec/common/string_ref.h" -#include "vec/core/types.h" -#include "vec/data_types/data_type_array.h" -#include "vec/data_types/data_type_nullable.h" -#include "vec/data_types/data_type_number.h" -#include "vec/io/io_helper.h" - -namespace doris { -namespace vectorized { -class Arena; -class BufferReadable; -class BufferWritable; -} // namespace vectorized -} // namespace doris - -namespace doris::vectorized { - -struct OldPercentileState { - std::vector vec_counts; - std::vector vec_quantile {-1}; - bool inited_flag = false; - - void write(BufferWritable& buf) const { - write_binary(inited_flag, buf); - int size_num = vec_quantile.size(); - write_binary(size_num, buf); - for (const auto& quantile : vec_quantile) { - write_binary(quantile, buf); - } - std::string serialize_str; - for (const auto& counts : vec_counts) { - serialize_str.resize(counts.serialized_size(), '0'); - counts.serialize((uint8_t*)serialize_str.c_str()); - write_binary(serialize_str, buf); - } - } - - void read(BufferReadable& buf) { - read_binary(inited_flag, buf); - int size_num = 0; - read_binary(size_num, buf); - double data = 0.0; - vec_quantile.clear(); - for (int i = 0; i < size_num; ++i) { - read_binary(data, buf); - vec_quantile.emplace_back(data); - } - StringRef ref; - vec_counts.clear(); - vec_counts.resize(size_num); - for (int i = 0; i < size_num; ++i) { - read_binary(ref, buf); - vec_counts[i].unserialize((uint8_t*)ref.data); - } - } - - void add(int64_t source, const PaddedPODArray& quantiles, int arg_size) { - if (!inited_flag) { - vec_counts.resize(arg_size); - vec_quantile.resize(arg_size, -1); - inited_flag = true; - for (int i = 0; i < arg_size; ++i) { - vec_quantile[i] = quantiles[i]; - } - } - for (int i = 0; i < arg_size; ++i) { - vec_counts[i].increment(source, 1); - } - } - - void merge(const OldPercentileState& rhs) { - if (!rhs.inited_flag) { - return; - } - int size_num = rhs.vec_quantile.size(); - if (!inited_flag) { - vec_counts.resize(size_num); - vec_quantile.resize(size_num, -1); - inited_flag = true; - } - - for (int i = 0; i < size_num; ++i) { - if (vec_quantile[i] == -1.0) { - vec_quantile[i] = rhs.vec_quantile[i]; - } - vec_counts[i].merge(&(rhs.vec_counts[i])); - } - } - - void reset() { - vec_counts.clear(); - vec_quantile.clear(); - inited_flag = false; - } - - double get() const { return vec_counts.empty() ? 0 : vec_counts[0].terminate(vec_quantile[0]); } - - void insert_result_into(IColumn& to) const { - auto& column_data = assert_cast(to).get_data(); - for (int i = 0; i < vec_counts.size(); ++i) { - column_data.push_back(vec_counts[i].terminate(vec_quantile[i])); - } - } -}; - -class AggregateFunctionPercentileOld final - : public IAggregateFunctionDataHelper { -public: - AggregateFunctionPercentileOld(const DataTypes& argument_types_) - : IAggregateFunctionDataHelper( - argument_types_) {} - - String get_name() const override { return "percentile"; } - - DataTypePtr get_return_type() const override { return std::make_shared(); } - - void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num, - Arena*) const override { - const auto& sources = - assert_cast&, TypeCheckOnRelease::DISABLE>(*columns[0]); - const auto& quantile = - assert_cast(*columns[1]); - AggregateFunctionPercentileOld::data(place).add(sources.get_int(row_num), - quantile.get_data(), 1); - } - - void reset(AggregateDataPtr __restrict place) const override { - AggregateFunctionPercentileOld::data(place).reset(); - } - - void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, - Arena*) const override { - AggregateFunctionPercentileOld::data(place).merge( - AggregateFunctionPercentileOld::data(rhs)); - } - - void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override { - AggregateFunctionPercentileOld::data(place).write(buf); - } - - void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf, - Arena*) const override { - AggregateFunctionPercentileOld::data(place).read(buf); - } - - void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { - auto& col = assert_cast(to); - col.insert_value(AggregateFunctionPercentileOld::data(place).get()); - } -}; - -class AggregateFunctionPercentileArrayOld final - : public IAggregateFunctionDataHelper { -public: - AggregateFunctionPercentileArrayOld(const DataTypes& argument_types_) - : IAggregateFunctionDataHelper( - argument_types_) {} - - String get_name() const override { return "percentile_array"; } - - DataTypePtr get_return_type() const override { - return std::make_shared(make_nullable(std::make_shared())); - } - - void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num, - Arena*) const override { - const auto& sources = - assert_cast&, TypeCheckOnRelease::DISABLE>(*columns[0]); - const auto& quantile_array = - assert_cast(*columns[1]); - const auto& offset_column_data = quantile_array.get_offsets(); - const auto& nested_column = assert_cast( - quantile_array.get_data()) - .get_nested_column(); - const auto& nested_column_data = - assert_cast(nested_column); - - AggregateFunctionPercentileArrayOld::data(place).add( - sources.get_int(row_num), nested_column_data.get_data(), - offset_column_data.data()[row_num] - offset_column_data[(ssize_t)row_num - 1]); - } - - void reset(AggregateDataPtr __restrict place) const override { - AggregateFunctionPercentileArrayOld::data(place).reset(); - } - - void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, - Arena*) const override { - AggregateFunctionPercentileArrayOld::data(place).merge( - AggregateFunctionPercentileArrayOld::data(rhs)); - } - - void serialize(ConstAggregateDataPtr __restrict place, BufferWritable& buf) const override { - AggregateFunctionPercentileArrayOld::data(place).write(buf); - } - - void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf, - Arena*) const override { - AggregateFunctionPercentileArrayOld::data(place).read(buf); - } - - void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override { - auto& to_arr = assert_cast(to); - auto& to_nested_col = to_arr.get_data(); - if (to_nested_col.is_nullable()) { - auto col_null = reinterpret_cast(&to_nested_col); - AggregateFunctionPercentileArrayOld::data(place).insert_result_into( - col_null->get_nested_column()); - col_null->get_null_map_data().resize_fill(col_null->get_nested_column().size(), 0); - } else { - AggregateFunctionPercentileArrayOld::data(place).insert_result_into(to_nested_col); - } - to_arr.get_offsets().push_back(to_nested_col.size()); - } -}; - -} // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/aggregate_functions/aggregate_function_stddev.cpp b/be/src/vec/aggregate_functions/aggregate_function_stddev.cpp index b9e39552395ffa..72448a419e95d9 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_stddev.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_stddev.cpp @@ -51,15 +51,6 @@ AggregateFunctionPtr create_function_single_value(const String& name, return nullptr; } -template -AggregateFunctionPtr create_aggregate_function_variance_samp_older(const std::string& name, - const DataTypes& argument_types, - const bool result_is_nullable) { - return create_function_single_value( - name, argument_types, result_is_nullable, true); -} - AggregateFunctionPtr create_aggregate_function_variance_samp(const std::string& name, const DataTypes& argument_types, const bool result_is_nullable) { @@ -67,15 +58,6 @@ AggregateFunctionPtr create_aggregate_function_variance_samp(const std::string& name, argument_types, result_is_nullable, false); } -template -AggregateFunctionPtr create_aggregate_function_stddev_samp_older(const std::string& name, - const DataTypes& argument_types, - const bool result_is_nullable) { - return create_function_single_value(name, argument_types, - result_is_nullable, true); -} - template AggregateFunctionPtr create_aggregate_function_variance_pop(const std::string& name, const DataTypes& argument_types, @@ -108,18 +90,8 @@ void register_aggregate_function_stddev_variance_pop(AggregateFunctionSimpleFact } void register_aggregate_function_stddev_variance_samp_old(AggregateFunctionSimpleFactory& factory) { - factory.register_alternative_function( - "variance_samp", create_aggregate_function_variance_samp_older, false, - AGG_FUNCTION_NULLABLE); - factory.register_alternative_function( - "variance_samp", create_aggregate_function_variance_samp_older, true, - AGG_FUNCTION_NULLABLE); - factory.register_alternative_function("stddev_samp", - create_aggregate_function_stddev_samp_older, - false, AGG_FUNCTION_NULLABLE); - factory.register_alternative_function("stddev_samp", - create_aggregate_function_stddev_samp_older, - true, AGG_FUNCTION_NULLABLE); + BeExecVersionManager::registe_restrict_function_compatibility("variance_samp"); + BeExecVersionManager::registe_restrict_function_compatibility("stddev_samp"); } void register_aggregate_function_stddev_variance_samp(AggregateFunctionSimpleFactory& factory) { diff --git a/be/src/vec/aggregate_functions/aggregate_function_stddev.h b/be/src/vec/aggregate_functions/aggregate_function_stddev.h index 5a8c896e1c3247..bcd35b13149ebf 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_stddev.h +++ b/be/src/vec/aggregate_functions/aggregate_function_stddev.h @@ -171,30 +171,6 @@ struct StddevSampName : Data { static const char* name() { return "stddev_samp"; } }; -template -struct SampData_OLDER : Data { - using ColVecResult = - std::conditional_t, ColumnDecimal, ColumnFloat64>; - void insert_result_into(IColumn& to) const { - ColumnNullable& nullable_column = assert_cast(to); - if (this->count == 1 || this->count == 0) { - nullable_column.insert_default(); - } else { - auto& col = assert_cast(nullable_column.get_nested_column()); - if constexpr (IsDecimalNumber) { - col.get_data().push_back(this->get_samp_result().value()); - } else { - col.get_data().push_back(this->get_samp_result()); - } - nullable_column.get_null_map_data().push_back(0); - } - } - - static DataTypePtr get_return_type() { - return make_nullable(std::make_shared>()); - } -}; - template struct SampData : Data { using ColVecResult = @@ -266,16 +242,6 @@ class AggregateFunctionSampVariance } }; -//samp function it's always nullables, it's need to handle nullable column -//so return type and add function should processing null values -template -class AggregateFunctionSamp_OLDER final - : public AggregateFunctionSampVariance { -public: - AggregateFunctionSamp_OLDER(const DataTypes& argument_types_) - : AggregateFunctionSampVariance(argument_types_) {} -}; - template class AggregateFunctionSamp final : public AggregateFunctionSampVariance { public: diff --git a/be/test/vec/aggregate_functions/vec_window_funnel_test.cpp b/be/test/vec/aggregate_functions/vec_window_funnel_test.cpp index af63b720e6a570..96a08421a8d096 100644 --- a/be/test/vec/aggregate_functions/vec_window_funnel_test.cpp +++ b/be/test/vec/aggregate_functions/vec_window_funnel_test.cpp @@ -58,7 +58,8 @@ class VWindowFunnelTest : public testing::Test { std::make_shared(), std::make_shared(), std::make_shared(), std::make_shared(), std::make_shared()}; - agg_function = factory.get("window_funnel", data_types, false, -1); + agg_function = factory.get("window_funnel", data_types, false, + BeExecVersionManager::get_newest_version()); EXPECT_NE(agg_function, nullptr); }