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;