diff --git a/src/Analyzer/Passes/AggregateFunctionOfGroupByKeysPass.cpp b/src/Analyzer/Passes/AggregateFunctionOfGroupByKeysPass.cpp index 0becf2164cf..3a89ab3a1fc 100644 --- a/src/Analyzer/Passes/AggregateFunctionOfGroupByKeysPass.cpp +++ b/src/Analyzer/Passes/AggregateFunctionOfGroupByKeysPass.cpp @@ -172,8 +172,11 @@ public: } -void AggregateFunctionOfGroupByKeysPass::run(QueryTreeNodePtr query_tree_node, ContextPtr /*context*/) +void AggregateFunctionOfGroupByKeysPass::run(QueryTreeNodePtr query_tree_node, ContextPtr context) { + if (!context->getSettingsRef().optimize_aggregators_of_group_by_keys) + return; + CollectQueryAndGroupByKeysVisitor collector; collector.visit(query_tree_node);