From 304c3679129280fd0b31dca75d3624ef92134e4f Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Mon, 26 Jul 2021 17:57:49 +0300 Subject: [PATCH] fix groupUniqArray --- .../AggregateFunctionGroupUniqArray.cpp | 12 ++++++------ .../AggregateFunctionGroupUniqArray.h | 8 ++++---- .../01156_pcg_deserialization.reference | 3 +++ .../0_stateless/01156_pcg_deserialization.sh | 18 +++++++++++------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp index 646d0341343..7709357189c 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp +++ b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.cpp @@ -25,8 +25,8 @@ template class AggregateFunctionGroupUniqArrayDate : public AggregateFunctionGroupUniqArray { public: - explicit AggregateFunctionGroupUniqArrayDate(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits::max()) - : AggregateFunctionGroupUniqArray(argument_type, max_elems_) {} + explicit AggregateFunctionGroupUniqArrayDate(const DataTypePtr & argument_type, const Array & parameters_, UInt64 max_elems_ = std::numeric_limits::max()) + : AggregateFunctionGroupUniqArray(argument_type, parameters_, max_elems_) {} DataTypePtr getReturnType() const override { return std::make_shared(std::make_shared()); } }; @@ -34,8 +34,8 @@ template class AggregateFunctionGroupUniqArrayDateTime : public AggregateFunctionGroupUniqArray { public: - explicit AggregateFunctionGroupUniqArrayDateTime(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits::max()) - : AggregateFunctionGroupUniqArray(argument_type, max_elems_) {} + explicit AggregateFunctionGroupUniqArrayDateTime(const DataTypePtr & argument_type, const Array & parameters_, UInt64 max_elems_ = std::numeric_limits::max()) + : AggregateFunctionGroupUniqArray(argument_type, parameters_, max_elems_) {} DataTypePtr getReturnType() const override { return std::make_shared(std::make_shared()); } }; @@ -102,9 +102,9 @@ AggregateFunctionPtr createAggregateFunctionGroupUniqArray( ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); if (!limit_size) - return createAggregateFunctionGroupUniqArrayImpl(name, argument_types[0]); + return createAggregateFunctionGroupUniqArrayImpl(name, argument_types[0], parameters); else - return createAggregateFunctionGroupUniqArrayImpl(name, argument_types[0], max_elems); + return createAggregateFunctionGroupUniqArrayImpl(name, argument_types[0], parameters, max_elems); } } diff --git a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h index ccba789483f..cec160ee21f 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h @@ -48,9 +48,9 @@ private: using State = AggregateFunctionGroupUniqArrayData; public: - AggregateFunctionGroupUniqArray(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits::max()) + AggregateFunctionGroupUniqArray(const DataTypePtr & argument_type, const Array & parameters_, UInt64 max_elems_ = std::numeric_limits::max()) : IAggregateFunctionDataHelper, - AggregateFunctionGroupUniqArray>({argument_type}, {}), + AggregateFunctionGroupUniqArray>({argument_type}, parameters_), max_elems(max_elems_) {} String getName() const override { return "groupUniqArray"; } @@ -152,8 +152,8 @@ class AggregateFunctionGroupUniqArrayGeneric using State = AggregateFunctionGroupUniqArrayGenericData; public: - AggregateFunctionGroupUniqArrayGeneric(const DataTypePtr & input_data_type_, UInt64 max_elems_ = std::numeric_limits::max()) - : IAggregateFunctionDataHelper>({input_data_type_}, {}) + AggregateFunctionGroupUniqArrayGeneric(const DataTypePtr & input_data_type_, const Array & parameters_, UInt64 max_elems_ = std::numeric_limits::max()) + : IAggregateFunctionDataHelper>({input_data_type_}, parameters_) , input_data_type(this->argument_types[0]) , max_elems(max_elems_) {} diff --git a/tests/queries/0_stateless/01156_pcg_deserialization.reference b/tests/queries/0_stateless/01156_pcg_deserialization.reference index e43b7ca3ceb..a41bc53d840 100644 --- a/tests/queries/0_stateless/01156_pcg_deserialization.reference +++ b/tests/queries/0_stateless/01156_pcg_deserialization.reference @@ -1,3 +1,6 @@ 5 5 5 5 5 5 +5 5 +5 5 +5 5 diff --git a/tests/queries/0_stateless/01156_pcg_deserialization.sh b/tests/queries/0_stateless/01156_pcg_deserialization.sh index 9c8ac29f32e..00ef86dce9c 100755 --- a/tests/queries/0_stateless/01156_pcg_deserialization.sh +++ b/tests/queries/0_stateless/01156_pcg_deserialization.sh @@ -4,16 +4,20 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # shellcheck source=../shell_config.sh . "$CURDIR"/../shell_config.sh +declare -a functions=("groupArraySample" "groupUniqArray") declare -a engines=("Memory" "MergeTree order by n" "Log") -for engine in "${engines[@]}" +for func in "${functions[@]}" do - $CLICKHOUSE_CLIENT -q "drop table if exists t"; - $CLICKHOUSE_CLIENT -q "create table t (n UInt8, a1 AggregateFunction(groupArraySample(1), UInt8)) engine=$engine" - $CLICKHOUSE_CLIENT -q "insert into t select number % 5 as n, groupArraySampleState(1)(toUInt8(number)) from numbers(10) group by n" + for engine in "${engines[@]}" + do + $CLICKHOUSE_CLIENT -q "drop table if exists t"; + $CLICKHOUSE_CLIENT -q "create table t (n UInt8, a1 AggregateFunction($func(1), UInt8)) engine=$engine" + $CLICKHOUSE_CLIENT -q "insert into t select number % 5 as n, ${func}State(1)(toUInt8(number)) from numbers(10) group by n" - $CLICKHOUSE_CLIENT -q "select * from t format TSV" | $CLICKHOUSE_CLIENT -q "insert into t format TSV" - $CLICKHOUSE_CLIENT -q "select countDistinct(n), countDistinct(a1) from t" + $CLICKHOUSE_CLIENT -q "select * from t format TSV" | $CLICKHOUSE_CLIENT -q "insert into t format TSV" + $CLICKHOUSE_CLIENT -q "select countDistinct(n), countDistinct(a1) from t" - $CLICKHOUSE_CLIENT -q "drop table t"; + $CLICKHOUSE_CLIENT -q "drop table t"; + done done