From 19528007fdb5782d03175892dd63a3c8c72e1652 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Wed, 6 May 2020 03:53:59 +0300 Subject: [PATCH] fix multiple usages of 'IN' operator with the same set --- src/Interpreters/ExpressionAnalyzer.cpp | 2 +- .../0_stateless/01136_multiple_sets.reference | 5 +++++ tests/queries/0_stateless/01136_multiple_sets.sql | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/queries/0_stateless/01136_multiple_sets.reference create mode 100644 tests/queries/0_stateless/01136_multiple_sets.sql diff --git a/src/Interpreters/ExpressionAnalyzer.cpp b/src/Interpreters/ExpressionAnalyzer.cpp index 0cbfb5c6ac5..4a94bc83368 100644 --- a/src/Interpreters/ExpressionAnalyzer.cpp +++ b/src/Interpreters/ExpressionAnalyzer.cpp @@ -409,7 +409,7 @@ bool ExpressionAnalyzer::makeAggregateDescriptions(ExpressionActionsPtr & action for (size_t i = 0; i < arguments.size(); ++i) { - getRootActions(arguments[i], true, actions); + getRootActionsNoMakeSet(arguments[i], true, actions); const std::string & name = arguments[i]->getColumnName(); types[i] = actions->getSampleBlock().getByName(name).type; aggregate.argument_names[i] = name; diff --git a/tests/queries/0_stateless/01136_multiple_sets.reference b/tests/queries/0_stateless/01136_multiple_sets.reference new file mode 100644 index 00000000000..7ac20ecffd3 --- /dev/null +++ b/tests/queries/0_stateless/01136_multiple_sets.reference @@ -0,0 +1,5 @@ +2 +2 +2 +1 +1 diff --git a/tests/queries/0_stateless/01136_multiple_sets.sql b/tests/queries/0_stateless/01136_multiple_sets.sql new file mode 100644 index 00000000000..bd865149551 --- /dev/null +++ b/tests/queries/0_stateless/01136_multiple_sets.sql @@ -0,0 +1,12 @@ +drop table if exists test; + +create table test (project LowCardinality(String)) engine=MergeTree() order by project; +insert into test values ('val1'), ('val2'), ('val3'); + +select sum(project in ('val1', 'val2')) from test; +set force_primary_key = 1; +select sum(project in ('val1', 'val2')) from test where project in ('val1', 'val2'); +select count() from test where project in ('val1', 'val2'); +select project in ('val1', 'val2') from test where project in ('val1', 'val2'); + +drop table test;