diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 69401587e41..fe352c59ead 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -6427,9 +6427,9 @@ std::optional MergeTreeData::getQueryProcessingStageWithAgg // Projections don't support grouping sets yet. if (original_select_query->group_by_with_grouping_sets - || select_query->group_by_with_totals - || select_query->group_by_with_rollup - || select_query->group_by_with_cube) + || original_select_query->group_by_with_totals + || original_select_query->group_by_with_rollup + || original_select_query->group_by_with_cube) return std::nullopt; auto query_options = SelectQueryOptions( @@ -6439,7 +6439,7 @@ std::optional MergeTreeData::getQueryProcessingStageWithAgg ).ignoreProjections().ignoreAlias(); InterpreterSelectQuery select( - query_ptr, + original_query_ptr, query_context, query_options, query_info.prepared_sets);