diff --git a/dbms/src/DataStreams/AggregatingSortedBlockInputStream.cpp b/dbms/src/DataStreams/AggregatingSortedBlockInputStream.cpp index 34fb19b2688..1be85f7e1b8 100644 --- a/dbms/src/DataStreams/AggregatingSortedBlockInputStream.cpp +++ b/dbms/src/DataStreams/AggregatingSortedBlockInputStream.cpp @@ -42,11 +42,14 @@ AggregatingSortedBlockInputStream::AggregatingSortedBlockInputStream( continue; } - if (auto simple_aggr = findSimpleAggregateFunction(column.type)) { + if (auto simple_aggr = findSimpleAggregateFunction(column.type)) + { // simple aggregate function SimpleAggregateDescription desc{simple_aggr->getFunction(), i}; columns_to_simple_aggregate.emplace_back(std::move(desc)); - } else { + } + else + { // standard aggregate function column_numbers_to_aggregate.push_back(i); } @@ -99,7 +102,8 @@ void AggregatingSortedBlockInputStream::merge(MutableColumns & merged_columns, s key_differs = next_key != current_key; /// if there are enough rows accumulated and the last one is calculated completely - if (key_differs && merged_rows >= max_block_size) { + if (key_differs && merged_rows >= max_block_size) + { /// Write the simple aggregation result for the previous group. insertSimpleAggregationResult(merged_columns); return; diff --git a/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.cpp b/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.cpp index 402ce86ad62..65bef22ce28 100644 --- a/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.cpp +++ b/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.cpp @@ -18,7 +18,8 @@ #include -namespace DB { +namespace DB +{ namespace ErrorCodes { @@ -33,13 +34,16 @@ const std::vector supported_functions = std::vector( {"any", "anyLast", "min", "max", "sum"}); -String DataTypeDomainSimpleAggregateFunction::doGetName() const { +String DataTypeDomainSimpleAggregateFunction::doGetName() const +{ std::stringstream stream; stream << "SimpleAggregateFunction(" << function->getName(); - if (!parameters.empty()) { + if (!parameters.empty()) + { stream << "("; - for (size_t i = 0; i < parameters.size(); ++i) { + for (size_t i = 0; i < parameters.size(); ++i) + { if (i) stream << ", "; stream << applyVisitor(DB::FieldVisitorToString(), parameters[i]); @@ -107,7 +111,8 @@ static std::pair create(const ASTPtr & arguments function = AggregateFunctionFactory::instance().get(function_name, argument_types, params_row); // check function - if (std::find(std::begin(supported_functions), std::end(supported_functions), function->getName()) == std::end(supported_functions)) { + if (std::find(std::begin(supported_functions), std::end(supported_functions), function->getName()) == std::end(supported_functions)) + { throw Exception("Unsupported aggregate function " + function->getName() + ", supported functions are " + boost::algorithm::join(supported_functions, ","), ErrorCodes::BAD_ARGUMENTS); } @@ -115,7 +120,8 @@ static std::pair create(const ASTPtr & arguments DataTypePtr storage_type = DataTypeFactory::instance().get(argument_types[0]->getName()); DataTypeDomainPtr domain = std::make_unique(storage_type, function, argument_types, params_row); - if (!function->getReturnType()->equals(*removeLowCardinality(storage_type))) { + if (!function->getReturnType()->equals(*removeLowCardinality(storage_type))) + { throw Exception("Incompatible data types between aggregate function '" + function->getName() + "' which returns " + function->getReturnType()->getName() + " and column storage type " + storage_type->getName(), ErrorCodes::BAD_ARGUMENTS); } @@ -123,7 +129,8 @@ static std::pair create(const ASTPtr & arguments return std::make_pair(storage_type, std::move(domain)); } -static const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(const IDataTypeDomain * domain) { +static const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(const IDataTypeDomain * domain) +{ if (domain == nullptr) return nullptr; @@ -136,7 +143,8 @@ static const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction return nullptr; } -const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(DataTypePtr dataType) { +const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(DataTypePtr dataType) +{ return findSimpleAggregateFunction(dataType->getDomain()); } diff --git a/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.h b/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.h index 70e94b1a652..6573f1ae5d0 100644 --- a/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.h +++ b/dbms/src/DataTypes/DataTypeDomainSimpleAggregateFunction.h @@ -24,7 +24,8 @@ namespace DB * Technically, a standard IDataType is instanciated and a DataTypeDomainSimpleAggregateFunction is added as domain. */ -class DataTypeDomainSimpleAggregateFunction : public IDataTypeDomain { +class DataTypeDomainSimpleAggregateFunction : public IDataTypeDomain +{ private: const DataTypePtr storage_type; const AggregateFunctionPtr function; diff --git a/dbms/src/DataTypes/IDataTypeDomain.h b/dbms/src/DataTypes/IDataTypeDomain.h index 1eed8afd808..a840964d28a 100644 --- a/dbms/src/DataTypes/IDataTypeDomain.h +++ b/dbms/src/DataTypes/IDataTypeDomain.h @@ -25,14 +25,16 @@ private: public: virtual ~IDataTypeDomain() {} - String getName() const { + String getName() const + { if (delegate) return delegate->getName(); else return doGetName(); } - void appendDomain(DataTypeDomainPtr delegate_) const { + void appendDomain(DataTypeDomainPtr delegate_) const + { if (delegate == nullptr) delegate = std::move(delegate_); else @@ -45,7 +47,8 @@ protected: virtual String doGetName() const = 0; }; -class IDataTypeDomainCustomSerialization : public IDataTypeDomain { +class IDataTypeDomainCustomSerialization : public IDataTypeDomain +{ public: virtual ~IDataTypeDomainCustomSerialization() {}