Reproducer: 
``` sql
SELECT count() FROM (SELECT queryID() AS t FROM remote('127.0.0.{1..3}', numbers(10)) WITH TOTALS HAVING t = initialQueryID())

Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: Chunk info was not set for chunk in GroupingAggregatedTransform.. (LOGICAL_ERROR)
``` 
{
                        unique_keys[key.name] = aggregation_keys.size();
                        aggregation_keys.push_back(key);
                        
                        aggregated_columns.push_back(std::move(key));
                    }
                }
            }
            if (!select_query->group_by_with_grouping_sets)
            {
                auto & list = aggregation_keys_indexes_list.emplace_back();
                for (size_t i = 0; i < aggregation_keys.size(); ++i)
                    list.push_back(i);
            }
            if (group_asts.empty())
            {
                select_query->setExpression(ASTSelectQuery::Expression::GROUP_BY, {});
                has_aggregation = select_query->having() || !aggregate_descriptions.empty();
            }
        }
        
        
        has_const_aggregation_keys = select_query->group_by_with_constant_keys;
    }
    else
        aggregated_columns = temp_actions->getNamesAndTypesList();
    for (const auto & desc : aggregate_descriptions)
        aggregated_columns.emplace_back(desc.column_name, desc.function->getReturnType());
}
void ExpressionAnalyzer::initGlobalSubqueriesAndExternalTables(bool do_global, bool is_explain)