From 63dc35780ed4b28bcf4a2dcdac16930279c4fe7d Mon Sep 17 00:00:00 2001 From: achimbab <07c00h@gmail.com> Date: Fri, 2 Apr 2021 11:58:58 +0900 Subject: [PATCH] More parameter checking and remove a useless function --- .../AggregateFunctionNull.h | 22 ------------------- .../AggregateFunctionSequenceNextNode.cpp | 9 ++++++-- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionNull.h b/src/AggregateFunctions/AggregateFunctionNull.h index 821398e715e..e1238182ab5 100644 --- a/src/AggregateFunctions/AggregateFunctionNull.h +++ b/src/AggregateFunctions/AggregateFunctionNull.h @@ -276,28 +276,6 @@ public: this->nested_function->add(this->nestedPlace(place), nested_columns, row_num, arena); } - void insertResultInto(AggregateDataPtr place, IColumn & to, Arena * arena) const override - { - if constexpr (result_is_nullable) - { - ColumnNullable & to_concrete = assert_cast(to); - if (this->getFlag(place)) - { - this->nested_function->insertResultInto(this->nestedPlace(place), to_concrete.getNestedColumn(), arena); - to_concrete.getNullMapData().push_back(0); - } - else - { - to_concrete.insertDefault(); - } - } - else - { - this->nested_function->insertResultInto(this->nestedPlace(place), to, arena); - } - } - - private: enum { MAX_ARGS = 8 }; size_t number_of_arguments = 0; diff --git a/src/AggregateFunctions/AggregateFunctionSequenceNextNode.cpp b/src/AggregateFunctions/AggregateFunctionSequenceNextNode.cpp index c3a42703e3d..6f2e2a5c3d7 100644 --- a/src/AggregateFunctions/AggregateFunctionSequenceNextNode.cpp +++ b/src/AggregateFunctions/AggregateFunctionSequenceNextNode.cpp @@ -66,13 +66,18 @@ createAggregateFunctionSequenceNode(const std::string & name, UInt64 max_events, throw Exception{"Aggregate function " + name + " doesn't support a parameter: " + param_base, ErrorCodes::BAD_ARGUMENTS}; SequenceBase base = seq_base_mapping[param_base]; + if ((base == SequenceBase::Head && direction == SequenceDirection::Backward) || + (base == SequenceBase::Tail && direction == SequenceDirection::Forward)) + throw Exception(fmt::format( + "Invalid argument combination of '{}' with '{}'", param_base, param_dir), ErrorCodes::BAD_ARGUMENTS); + if (argument_types.size() < min_required_args) - throw Exception("Aggregate function " + name + " requires at least two arguments.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); + throw Exception("Aggregate function " + name + " requires at least " + toString(min_required_args) + " arguments.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); bool is_base_match_type = base == SequenceBase::FirstMatch || base == SequenceBase::LastMatch; if (is_base_match_type && argument_types.size() < min_required_args + 1) throw Exception( - "Aggregate function " + name + " requires at least three arguments when base is first_match or last_match.", + "Aggregate function " + name + " requires at least " + toString(min_required_args + 1) + " arguments when base is first_match or last_match.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); if (argument_types.size() > max_events + min_required_args)