|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +#include <fmt/format.h> |
| 19 | + |
| 20 | +#include <string> |
| 21 | + |
| 22 | +#include "common/logging.h" |
| 23 | +#include "vec/aggregate_functions/aggregate_function_regr_sxx_.h" |
| 24 | +#include "vec/aggregate_functions/aggregate_function_simple_factory.h" |
| 25 | +#include "vec/aggregate_functions/helpers.h" |
| 26 | +#include "vec/data_types/data_type.h" |
| 27 | +#include "vec/data_types/data_type_nullable.h" |
| 28 | + |
| 29 | +namespace doris::vectorized { |
| 30 | + |
| 31 | +AggregateFunctionPtr create_function_regr_sxx(const String& name, const DataTypes& argument_types, |
| 32 | + const bool result_is_nullable) { |
| 33 | + WhichDataType which(remove_nullable(argument_types[0])); |
| 34 | +#define DISPATCH(TYPE) \ |
| 35 | + if (which.idx == TypeIndex::TYPE) \ |
| 36 | + return creator_without_type::create<AggregateFunctionRegrFunc< \ |
| 37 | + TYPE, RegrSxxName<RegrSxxData<TYPE, AggregateFunctionRegrSxxData<TYPE>>>>>( \ |
| 38 | + argument_types, result_is_nullable); |
| 39 | + FOR_DECIMAL_TYPES(DISPATCH) |
| 40 | + FOR_NUMERIC_TYPES(DISPATCH) |
| 41 | +#undef DISPATCH |
| 42 | + |
| 43 | + LOG(WARNING) << fmt::format("create_function_single_value with unknowed type {}", |
| 44 | + argument_types[0]->get_name()); |
| 45 | + return nullptr; |
| 46 | +} |
| 47 | + |
| 48 | +AggregateFunctionPtr create_function_regr_sxy(const String& name, const DataTypes& argument_types, |
| 49 | + const bool result_is_nullable) { |
| 50 | + WhichDataType which(remove_nullable(argument_types[0])); |
| 51 | +#define DISPATCH(TYPE) \ |
| 52 | + if (which.idx == TypeIndex::TYPE) \ |
| 53 | + return creator_without_type::create<AggregateFunctionRegrFunc< \ |
| 54 | + TYPE, RegrSxyName<RegrSxyData<TYPE, AggregateFunctionRegrSxyData<TYPE>>>>>( \ |
| 55 | + argument_types, result_is_nullable); |
| 56 | + FOR_DECIMAL_TYPES(DISPATCH) |
| 57 | + FOR_NUMERIC_TYPES(DISPATCH) |
| 58 | +#undef DISPATCH |
| 59 | + |
| 60 | + LOG(WARNING) << fmt::format("create_function_single_value with unknowed type {}", |
| 61 | + argument_types[0]->get_name()); |
| 62 | + return nullptr; |
| 63 | +} |
| 64 | + |
| 65 | +AggregateFunctionPtr create_function_regr_syy(const String& name, const DataTypes& argument_types, |
| 66 | + const bool result_is_nullable) { |
| 67 | + WhichDataType which(remove_nullable(argument_types[0])); |
| 68 | +#define DISPATCH(TYPE) \ |
| 69 | + if (which.idx == TypeIndex::TYPE) \ |
| 70 | + return creator_without_type::create<AggregateFunctionRegrFunc< \ |
| 71 | + TYPE, RegrSyyName<RegrSyyData<TYPE, AggregateFunctionRegrSyyData<TYPE>>>>>( \ |
| 72 | + argument_types, result_is_nullable); |
| 73 | + FOR_DECIMAL_TYPES(DISPATCH) |
| 74 | + FOR_NUMERIC_TYPES(DISPATCH) |
| 75 | +#undef DISPATCH |
| 76 | + |
| 77 | + LOG(WARNING) << fmt::format("create_function_single_value with unknowed type {}", |
| 78 | + argument_types[0]->get_name()); |
| 79 | + return nullptr; |
| 80 | +} |
| 81 | + |
| 82 | +AggregateFunctionPtr create_aggregate_function_regr_sxx(const std::string& name, |
| 83 | + const DataTypes& argument_types, |
| 84 | + const bool result_is_nullable) { |
| 85 | + return create_function_regr_sxx(name, argument_types, result_is_nullable); |
| 86 | +} |
| 87 | + |
| 88 | +AggregateFunctionPtr create_aggregate_function_regr_sxy(const std::string& name, |
| 89 | + const DataTypes& argument_types, |
| 90 | + const bool result_is_nullable) { |
| 91 | + return create_function_regr_sxy(name, argument_types, result_is_nullable); |
| 92 | +} |
| 93 | + |
| 94 | +AggregateFunctionPtr create_aggregate_function_regr_syy(const std::string& name, |
| 95 | + const DataTypes& argument_types, |
| 96 | + const bool result_is_nullable) { |
| 97 | + return create_function_regr_syy(name, argument_types, result_is_nullable); |
| 98 | +} |
| 99 | + |
| 100 | +void register_aggregate_function_regr_mixed(AggregateFunctionSimpleFactory& factory) { |
| 101 | + factory.register_function_both("regr_sxx", create_aggregate_function_regr_sxx); |
| 102 | + factory.register_function_both("regr_sxy", create_aggregate_function_regr_sxy); |
| 103 | + factory.register_function_both("regr_syy", create_aggregate_function_regr_syy); |
| 104 | +} |
| 105 | +} // namespace doris::vectorized |
0 commit comments