mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Remove AggregateFunctionCountNotNullVariadic
This commit is contained in:
parent
99f531c58f
commit
7adad4251f
@ -113,69 +113,4 @@ public:
|
|||||||
const char * getHeaderFilePath() const override { return __FILE__; }
|
const char * getHeaderFilePath() const override { return __FILE__; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Count number of calls where all arguments are not NULL.
|
|
||||||
class AggregateFunctionCountNotNullVariadic final : public IAggregateFunctionDataHelper<AggregateFunctionCountData, AggregateFunctionCountNotNullVariadic>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AggregateFunctionCountNotNullVariadic(const DataTypes & arguments, const Array & params)
|
|
||||||
: IAggregateFunctionDataHelper<AggregateFunctionCountData, AggregateFunctionCountNotNullVariadic>(arguments, params)
|
|
||||||
{
|
|
||||||
number_of_arguments = arguments.size();
|
|
||||||
|
|
||||||
if (number_of_arguments == 1)
|
|
||||||
throw Exception("Logical error: single argument is passed to AggregateFunctionCountNotNullVariadic", ErrorCodes::LOGICAL_ERROR);
|
|
||||||
|
|
||||||
if (number_of_arguments > MAX_ARGS)
|
|
||||||
throw Exception("Maximum number of arguments for aggregate function with Nullable types is " + toString(size_t(MAX_ARGS)),
|
|
||||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < number_of_arguments; ++i)
|
|
||||||
is_nullable[i] = arguments[i]->isNullable();
|
|
||||||
}
|
|
||||||
|
|
||||||
String getName() const override { return "count"; }
|
|
||||||
|
|
||||||
DataTypePtr getReturnType() const override
|
|
||||||
{
|
|
||||||
return std::make_shared<DataTypeUInt64>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < number_of_arguments; ++i)
|
|
||||||
if (is_nullable[i] && assert_cast<const ColumnNullable &>(*columns[i]).isNullAt(row_num))
|
|
||||||
return;
|
|
||||||
|
|
||||||
++data(place).count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override
|
|
||||||
{
|
|
||||||
data(place).count += data(rhs).count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const override
|
|
||||||
{
|
|
||||||
writeVarUInt(data(place).count, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void deserialize(AggregateDataPtr place, ReadBuffer & buf, Arena *) const override
|
|
||||||
{
|
|
||||||
readVarUInt(data(place).count, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void insertResultInto(ConstAggregateDataPtr place, IColumn & to) const override
|
|
||||||
{
|
|
||||||
assert_cast<ColumnUInt64 &>(to).getData().push_back(data(place).count);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * getHeaderFilePath() const override { return __FILE__; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum { MAX_ARGS = 8 };
|
|
||||||
size_t number_of_arguments = 0;
|
|
||||||
std::array<char, MAX_ARGS> is_nullable; /// Plain array is better than std::vector due to one indirection less.
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,7 @@ public:
|
|||||||
/// Special case for 'count' function. It could be called with Nullable arguments
|
/// Special case for 'count' function. It could be called with Nullable arguments
|
||||||
/// - that means - count number of calls, when all arguments are not NULL.
|
/// - that means - count number of calls, when all arguments are not NULL.
|
||||||
if (nested_function && nested_function->getName() == "count")
|
if (nested_function && nested_function->getName() == "count")
|
||||||
{
|
return std::make_shared<AggregateFunctionCountNotNullUnary>(arguments[0], params);
|
||||||
if (arguments.size() == 1)
|
|
||||||
return std::make_shared<AggregateFunctionCountNotNullUnary>(arguments[0], params);
|
|
||||||
else
|
|
||||||
return std::make_shared<AggregateFunctionCountNotNullVariadic>(arguments, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (has_null_types)
|
if (has_null_types)
|
||||||
return std::make_shared<AggregateFunctionNothing>(arguments, params);
|
return std::make_shared<AggregateFunctionNothing>(arguments, params);
|
||||||
|
Loading…
Reference in New Issue
Block a user