From 487fb09ff670a379deddc953b2bd1f52d3c77a39 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Sat, 20 Feb 2021 14:11:01 +0800 Subject: [PATCH] Suppress signed overflow in AggregateFunctionGroupArrayMoving 2 --- src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h | 6 +++--- tests/queries/0_stateless/01177_group_array_moving.sql | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h b/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h index 2a713f3aed2..3bab831d316 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h @@ -52,7 +52,7 @@ struct MovingSumData : public MovingData { static constexpr auto name = "groupArrayMovingSum"; - T get(size_t idx, UInt64 window_size) const + T NO_SANITIZE_UNDEFINED get(size_t idx, UInt64 window_size) const { if (idx < window_size) return this->value[idx]; @@ -66,7 +66,7 @@ struct MovingAvgData : public MovingData { static constexpr auto name = "groupArrayMovingAvg"; - T get(size_t idx, UInt64 window_size) const + T NO_SANITIZE_UNDEFINED get(size_t idx, UInt64 window_size) const { if (idx < window_size) return this->value[idx] / window_size; @@ -114,7 +114,7 @@ public: return std::make_shared(std::make_shared()); } - void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena) const override + void NO_SANITIZE_UNDEFINED add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena) const override { auto value = static_cast(*columns[0]).getData()[row_num]; this->data(place).add(static_cast(value), arena); diff --git a/tests/queries/0_stateless/01177_group_array_moving.sql b/tests/queries/0_stateless/01177_group_array_moving.sql index b1969e204fc..5689cd95f75 100644 --- a/tests/queries/0_stateless/01177_group_array_moving.sql +++ b/tests/queries/0_stateless/01177_group_array_moving.sql @@ -1,2 +1,4 @@ SELECT groupArrayMovingSum(257)(-9223372036854775808), groupArrayMovingSum(1048575)(18446744073709551615), groupArrayMovingSum(9223372036854775807)(number * 9223372036854775807) FROM remote('127.0.0.{1..2}', numbers(3)); SELECT groupArrayMovingAvg(257)(-9223372036854775808), groupArrayMovingAvg(1048575)(18446744073709551615), groupArrayMovingAvg(9223372036854775807)(number * 9223372036854775807) FROM remote('127.0.0.{1..2}', numbers(3)); + +SELECT groupArrayMovingSum(257)(-9223372036854775808), groupArrayMovingSum(1)(10.000100135803223, [NULL, NULL], NULL), groupArrayMovingSum(NULL)(NULL) FROM numbers(1023) FORMAT Null;