From 50bdea3c76d106c4354e903bf4bc14e75ca263ad Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 30 Mar 2023 09:57:17 +0200 Subject: [PATCH 1/3] Fix bug in aggregate functions JIT --- src/Core/Settings.h | 2 +- .../02703_jit_external_aggregation.reference | 1 + .../02703_jit_external_aggregation.sh | 35 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/02703_jit_external_aggregation.reference create mode 100755 tests/queries/0_stateless/02703_jit_external_aggregation.sh diff --git a/src/Core/Settings.h b/src/Core/Settings.h index fe8e9d4dc7d..5ab44fa2c1e 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -129,7 +129,7 @@ class IColumn; M(Bool, allow_suspicious_fixed_string_types, false, "In CREATE TABLE statement allows creating columns of type FixedString(n) with n > 256. FixedString with length >= 256 is suspicious and most likely indicates misusage", 0) \ M(Bool, compile_expressions, true, "Compile some scalar functions and operators to native code.", 0) \ M(UInt64, min_count_to_compile_expression, 3, "The number of identical expressions before they are JIT-compiled", 0) \ - M(Bool, compile_aggregate_expressions, true, "Compile aggregate functions to native code.", 0) \ + M(Bool, compile_aggregate_expressions, false, "Compile aggregate functions to native code. This feature has a bug and should not be used.", 0) \ M(UInt64, min_count_to_compile_aggregate_expression, 3, "The number of identical aggregate expressions before they are JIT-compiled", 0) \ M(Bool, compile_sort_description, true, "Compile sort description to native code.", 0) \ M(UInt64, min_count_to_compile_sort_description, 3, "The number of identical sort descriptions before they are JIT-compiled", 0) \ diff --git a/tests/queries/0_stateless/02703_jit_external_aggregation.reference b/tests/queries/0_stateless/02703_jit_external_aggregation.reference new file mode 100644 index 00000000000..cdeec60f4ef --- /dev/null +++ b/tests/queries/0_stateless/02703_jit_external_aggregation.reference @@ -0,0 +1 @@ +..... diff --git a/tests/queries/0_stateless/02703_jit_external_aggregation.sh b/tests/queries/0_stateless/02703_jit_external_aggregation.sh new file mode 100755 index 00000000000..386d4cd0e3c --- /dev/null +++ b/tests/queries/0_stateless/02703_jit_external_aggregation.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Tags: long + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# This query should return empty result in every of five runs: + +for _ in {1..5} +do + $CLICKHOUSE_CLIENT --query " +SELECT + COUNT() AS c, + group_key, + anyIf(r, key = 0) AS x0, + anyIf(r, key = 1) AS x1, + anyIf(r, key = 2) AS x2 +FROM +( + SELECT + CRC32(toString(number)) % 1000000 AS group_key, + number % 3 AS key, + number AS r + FROM numbers(10000000) +) +GROUP BY group_key +HAVING (c = 2) AND (x0 > 0) AND (x1 > 0) AND (x2 > 0) +ORDER BY group_key ASC +LIMIT 10 +SETTINGS max_bytes_before_external_group_by = 200000 +" && echo -n '.' +done + +echo From 2d153664dc3946c4b50f4c171fa6829f95b9d5bc Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 30 Mar 2023 13:13:33 +0300 Subject: [PATCH 2/3] Update 02703_jit_external_aggregation.sh --- tests/queries/0_stateless/02703_jit_external_aggregation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/02703_jit_external_aggregation.sh b/tests/queries/0_stateless/02703_jit_external_aggregation.sh index 386d4cd0e3c..2e56177a339 100755 --- a/tests/queries/0_stateless/02703_jit_external_aggregation.sh +++ b/tests/queries/0_stateless/02703_jit_external_aggregation.sh @@ -9,7 +9,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) for _ in {1..5} do - $CLICKHOUSE_CLIENT --query " + $CLICKHOUSE_CLIENT --compile_aggregate_expressions 0 --query " SELECT COUNT() AS c, group_key, From 15222fe1965e4990b17f0353cfa5152ed2f943dc Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 5 Apr 2023 18:17:02 +0300 Subject: [PATCH 3/3] Update 02703_jit_external_aggregation.sh --- tests/queries/0_stateless/02703_jit_external_aggregation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/02703_jit_external_aggregation.sh b/tests/queries/0_stateless/02703_jit_external_aggregation.sh index 2e56177a339..d1af5b8b8bc 100755 --- a/tests/queries/0_stateless/02703_jit_external_aggregation.sh +++ b/tests/queries/0_stateless/02703_jit_external_aggregation.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Tags: long +# Tags: long, no-asan, no-msan, no-tsan, no-ubsan CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # shellcheck source=../shell_config.sh