From 5742cfe201d4ecb208230ae147e5c9b8dc4fd24c Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 22 Nov 2023 12:27:56 +0000 Subject: [PATCH 1/4] Add a test from fuzzer --- tests/queries/0_stateless/02915_analyzer_fuzz_2.reference | 0 tests/queries/0_stateless/02915_analyzer_fuzz_2.sql | 5 +++++ 2 files changed, 5 insertions(+) create mode 100644 tests/queries/0_stateless/02915_analyzer_fuzz_2.reference create mode 100644 tests/queries/0_stateless/02915_analyzer_fuzz_2.sql diff --git a/tests/queries/0_stateless/02915_analyzer_fuzz_2.reference b/tests/queries/0_stateless/02915_analyzer_fuzz_2.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql b/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql new file mode 100644 index 00000000000..3ea3ce500f2 --- /dev/null +++ b/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql @@ -0,0 +1,5 @@ +SET aggregate_functions_null_for_empty = 1; +set allow_experimental_analyzer=1; +create table t_delete_projection (x UInt32, y UInt64, projection p (select sum(y))) engine = MergeTree order by tuple() SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; +insert into t_delete_projection select number, toString(number) from numbers(8192 * 10); + From 390c27f7d812314b98764f6296d82f7885010536 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 29 Nov 2023 16:16:22 +0000 Subject: [PATCH 2/4] Ignore aggregate_functions_null_for_empty for projections at insert. --- src/Storages/ProjectionsDescription.cpp | 7 ++++++- tests/queries/0_stateless/02915_analyzer_fuzz_2.sql | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Storages/ProjectionsDescription.cpp b/src/Storages/ProjectionsDescription.cpp index cddf252a7e1..258bb7b83ed 100644 --- a/src/Storages/ProjectionsDescription.cpp +++ b/src/Storages/ProjectionsDescription.cpp @@ -291,9 +291,14 @@ void ProjectionDescription::recalculateWithNewColumns(const ColumnsDescription & Block ProjectionDescription::calculate(const Block & block, ContextPtr context) const { + auto mut_context = Context::createCopy(context); + /// We ignore aggregate_functions_null_for_empty cause it changes aggregate function types. + /// Now, projections do not support in on SELECT, and (whith this change) should ignore on INSERT as well. + mut_context->setSetting("aggregate_functions_null_for_empty", Field(0)); + auto builder = InterpreterSelectQuery( query_ast, - context, + mut_context, Pipe(std::make_shared(block)), SelectQueryOptions{ type == ProjectionDescription::Type::Normal ? QueryProcessingStage::FetchColumns diff --git a/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql b/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql index 3ea3ce500f2..ca9fff68446 100644 --- a/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql +++ b/tests/queries/0_stateless/02915_analyzer_fuzz_2.sql @@ -1,5 +1,5 @@ SET aggregate_functions_null_for_empty = 1; -set allow_experimental_analyzer=1; +--set allow_experimental_analyzer=1; create table t_delete_projection (x UInt32, y UInt64, projection p (select sum(y))) engine = MergeTree order by tuple() SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; insert into t_delete_projection select number, toString(number) from numbers(8192 * 10); From dc43a36ee2faf54bc8ff11b06bd61e70dc399075 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 29 Nov 2023 16:40:18 +0000 Subject: [PATCH 3/4] Fixing style --- src/Storages/ProjectionsDescription.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/ProjectionsDescription.cpp b/src/Storages/ProjectionsDescription.cpp index 258bb7b83ed..ee847a42c71 100644 --- a/src/Storages/ProjectionsDescription.cpp +++ b/src/Storages/ProjectionsDescription.cpp @@ -293,7 +293,7 @@ Block ProjectionDescription::calculate(const Block & block, ContextPtr context) { auto mut_context = Context::createCopy(context); /// We ignore aggregate_functions_null_for_empty cause it changes aggregate function types. - /// Now, projections do not support in on SELECT, and (whith this change) should ignore on INSERT as well. + /// Now, projections do not support in on SELECT, and (with this change) should ignore on INSERT as well. mut_context->setSetting("aggregate_functions_null_for_empty", Field(0)); auto builder = InterpreterSelectQuery( From a36c11b21e721b4ba4ab4c4b2328bf4cc574eee6 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Wed, 29 Nov 2023 17:30:22 +0000 Subject: [PATCH 4/4] Disable transform_null_in as well just in case. --- src/Storages/ProjectionsDescription.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Storages/ProjectionsDescription.cpp b/src/Storages/ProjectionsDescription.cpp index ee847a42c71..08ebe3a10d0 100644 --- a/src/Storages/ProjectionsDescription.cpp +++ b/src/Storages/ProjectionsDescription.cpp @@ -295,6 +295,7 @@ Block ProjectionDescription::calculate(const Block & block, ContextPtr context) /// We ignore aggregate_functions_null_for_empty cause it changes aggregate function types. /// Now, projections do not support in on SELECT, and (with this change) should ignore on INSERT as well. mut_context->setSetting("aggregate_functions_null_for_empty", Field(0)); + mut_context->setSetting("transform_null_in", Field(0)); auto builder = InterpreterSelectQuery( query_ast,