From 49e57c555d8c253f96ebd6e59236eead28797b20 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 11 May 2020 03:16:50 +0300 Subject: [PATCH] Fixed code; added a test --- .../AggregateFunctionStatistics.h | 14 +++++++------- src/Functions/randomString.cpp | 3 ++- .../0_stateless/01276_random_string.reference | 1 + tests/queries/0_stateless/01276_random_string.sql | 1 + 4 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 tests/queries/0_stateless/01276_random_string.reference create mode 100644 tests/queries/0_stateless/01276_random_string.sql diff --git a/src/AggregateFunctions/AggregateFunctionStatistics.h b/src/AggregateFunctions/AggregateFunctionStatistics.h index 1614e265ccb..c691559b3f2 100644 --- a/src/AggregateFunctions/AggregateFunctionStatistics.h +++ b/src/AggregateFunctions/AggregateFunctionStatistics.h @@ -153,7 +153,7 @@ public: */ struct AggregateFunctionVarSampImpl { - static constexpr auto name = "varSamp"; + static constexpr auto name = "varSampStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -168,7 +168,7 @@ struct AggregateFunctionVarSampImpl */ struct AggregateFunctionStdDevSampImpl { - static constexpr auto name = "stddevSamp"; + static constexpr auto name = "stddevSampStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -180,7 +180,7 @@ struct AggregateFunctionStdDevSampImpl */ struct AggregateFunctionVarPopImpl { - static constexpr auto name = "varPop"; + static constexpr auto name = "varPopStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -197,7 +197,7 @@ struct AggregateFunctionVarPopImpl */ struct AggregateFunctionStdDevPopImpl { - static constexpr auto name = "stddevPop"; + static constexpr auto name = "stddevPopStable"; static inline Float64 apply(Float64 m2, UInt64 count) { @@ -405,7 +405,7 @@ public: */ struct AggregateFunctionCovarSampImpl { - static constexpr auto name = "covarSamp"; + static constexpr auto name = "covarSampStable"; static inline Float64 apply(Float64 co_moment, UInt64 count) { @@ -420,7 +420,7 @@ struct AggregateFunctionCovarSampImpl */ struct AggregateFunctionCovarPopImpl { - static constexpr auto name = "covarPop"; + static constexpr auto name = "covarPopStable"; static inline Float64 apply(Float64 co_moment, UInt64 count) { @@ -437,7 +437,7 @@ struct AggregateFunctionCovarPopImpl */ struct AggregateFunctionCorrImpl { - static constexpr auto name = "corr"; + static constexpr auto name = "corrStable"; static inline Float64 apply(Float64 co_moment, Float64 left_m2, Float64 right_m2, UInt64 count) { diff --git a/src/Functions/randomString.cpp b/src/Functions/randomString.cpp index eb0dcf6b21a..0929bbad7f8 100644 --- a/src/Functions/randomString.cpp +++ b/src/Functions/randomString.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace DB @@ -78,7 +79,7 @@ public: pos += sizeof(UInt64)) // We have padding in column buffers that we can overwrite. { UInt64 rand = thread_local_rng(); - *reinterpret_cast(data_to_ptr + pos) = rand; + unalignedStore(data_to_ptr + pos, rand); } data_to[offset + length] = 0; diff --git a/tests/queries/0_stateless/01276_random_string.reference b/tests/queries/0_stateless/01276_random_string.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/tests/queries/0_stateless/01276_random_string.reference @@ -0,0 +1 @@ +1 diff --git a/tests/queries/0_stateless/01276_random_string.sql b/tests/queries/0_stateless/01276_random_string.sql new file mode 100644 index 00000000000..5a86d88b290 --- /dev/null +++ b/tests/queries/0_stateless/01276_random_string.sql @@ -0,0 +1 @@ +SELECT DISTINCT c > 30000 FROM (SELECT arrayJoin(arrayMap(x -> reinterpretAsUInt8(substring(randomString(100), x + 1, 1)), range(100))) AS byte, count() AS c FROM numbers(100000) GROUP BY byte ORDER BY byte);