create STREAM tab (a int32, b int32, c int32, d int32) engine = MergeTree order by (a, b, c);
insert into tab select 0, number % 3, 2 - int_div(number, 3), (number % 3 + 1) 10 from numbers(6);
insert into tab select 0, number % 3, 2 - int_div(number, 3), (number % 3 + 1) 100 from numbers(6);
select * from (explain actions = 1, sorting=1 select a, any(b), c, d from tab where b = 1 group by a, c, d settings optimize_aggregation_in_order=1, query_plan_aggregation_in_order=1) where explain like '%Sorting (Stream)%' or explain like '%ReadFromMergeTree%' or explain like '%Aggregating%' or explain like '%Order:%';
Expected Result:
the above can run without problem.
**How to reproduce**
**Error message and/or stacktrace**
<!-- If applicable, add screenshots to help explain your problem. -->
**Additional context**
<!--Add any other context about the problem here. -->
Describe what's wrong
insert into tab select 0, number % 3, 2 - int_div(number, 3), (number % 3 + 1) 10 from numbers(6); insert into tab select 0, number % 3, 2 - int_div(number, 3), (number % 3 + 1) 100 from numbers(6);
select * from (explain actions = 1, sorting=1 select a, any(b), c, d from tab where b = 1 group by a, c, d settings optimize_aggregation_in_order=1, query_plan_aggregation_in_order=1) where explain like '%Sorting (Stream)%' or explain like '%ReadFromMergeTree%' or explain like '%Aggregating%' or explain like '%Order:%';