mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix error
This commit is contained in:
parent
e116346cbb
commit
4fe75ad168
@ -16,7 +16,7 @@ namespace
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct SumSimple
|
||||
struct SumCountType
|
||||
{
|
||||
/// @note It uses slow Decimal128 (cause we need such a variant). sumWithOverflow is faster for Decimal32/64
|
||||
using ResultType = std::conditional_t<IsDecimalNumber<T>,
|
||||
@ -27,8 +27,7 @@ struct SumSimple
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename T> using AggregateFunctionSumCountSimple = typename SumSimple<T>::Function;
|
||||
template <typename T> using AggregateFunctionSumCountFunc = typename SumCountType<T>::Function;
|
||||
|
||||
template <template <typename> class Function>
|
||||
AggregateFunctionPtr createAggregateFunctionSumCount(const std::string & name, const DataTypes & argument_types, const Array & parameters)
|
||||
@ -53,7 +52,7 @@ AggregateFunctionPtr createAggregateFunctionSumCount(const std::string & name, c
|
||||
|
||||
void registerAggregateFunctionSumCount(AggregateFunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction("sumCount", createAggregateFunctionSumCount<AggregateFunctionSumCountSimple>);
|
||||
factory.registerFunction("sumCount", createAggregateFunctionSumCount<AggregateFunctionSumCountFunc>);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ struct AggregateFunctionSumCountData
|
||||
++ptr;
|
||||
}
|
||||
Impl::add(sum, local_sum);
|
||||
count += tmp_count;
|
||||
count += tmp_count;
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
@ -189,14 +189,10 @@ public:
|
||||
{
|
||||
DataTypes types;
|
||||
if constexpr (IsDecimalNumber<T>)
|
||||
{
|
||||
types.emplace_back(std::make_shared<ResultDataType>(ResultDataType::maxPrecision(), scale));
|
||||
}
|
||||
else
|
||||
{
|
||||
types.emplace_back(std::make_shared<ResultDataType>());
|
||||
}
|
||||
|
||||
|
||||
types.emplace_back(std::make_shared<DataTypeUInt64>());
|
||||
|
||||
return std::make_shared<DataTypeTuple>(types);
|
||||
|
@ -409,7 +409,7 @@ class IColumn;
|
||||
M(Bool, allow_non_metadata_alters, true, "Allow to execute alters which affects not only tables metadata, but also data on disk", 0) \
|
||||
M(Bool, enable_global_with_statement, true, "Propagate WITH statements to UNION queries and all subqueries", 0) \
|
||||
M(Bool, aggregate_functions_null_for_empty, false, "Rewrite all aggregate functions in a query, adding -OrNull suffix to them", 0) \
|
||||
M(Bool, optimize_fuse_sum_count_avg, false, "If enabled, Fuse aggregate functions when exsit at least two: sum, avg, count functions with identical argument to sumCount", 0) \
|
||||
M(Bool, optimize_fuse_sum_count_avg, false, "If enabled, Fuse aggregate functions when exists at least two: sum, avg, count functions with identical argument to sumCount", 0) \
|
||||
M(Bool, flatten_nested, true, "If true, columns of type Nested will be flatten to separate array columns instead of one array of tuples", 0) \
|
||||
M(Bool, asterisk_include_materialized_columns, false, "Include MATERIALIZED columns for wildcard query", 0) \
|
||||
M(Bool, asterisk_include_alias_columns, false, "Include ALIAS columns for wildcard query", 0) \
|
||||
|
@ -188,7 +188,7 @@ struct CustomizeFuseAggregateFunctionsData
|
||||
|
||||
std::map<String, UInt8> fuse_info;
|
||||
|
||||
inline UInt8 BitCount(UInt8 n) const
|
||||
static inline UInt8 bitCount(UInt8 n)
|
||||
{
|
||||
UInt8 c = 0;
|
||||
for (c = 0; n; n >>= 1)
|
||||
@ -204,14 +204,14 @@ struct CustomizeFuseAggregateFunctionsData
|
||||
if (!ident)
|
||||
return;
|
||||
auto column = fuse_info.find(ident->name());
|
||||
if (column != fuse_info.end() && BitCount(column->second) > 1)
|
||||
if (column != fuse_info.end() && bitCount(column->second) > 1)
|
||||
{
|
||||
auto func_base = makeASTFunction("sumCount", func.arguments->children.at(0)->clone());
|
||||
auto exp_list = std::make_shared<ASTExpressionList>();
|
||||
|
||||
if (func.name == "sum" || func.name == "count")
|
||||
{
|
||||
// Rewrite "sum" to sumCount().1, rewrite "count" to sumCount().2
|
||||
/// Rewrite "sum" to sumCount().1, rewrite "count" to sumCount().2
|
||||
UInt8 idx = (func.name == "sum" ? 1 : 2);
|
||||
func.name = "tupleElement";
|
||||
exp_list->children.push_back(func_base);
|
||||
@ -219,7 +219,7 @@ struct CustomizeFuseAggregateFunctionsData
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rewrite "avg" to sumCount().1 / sumCount().2
|
||||
/// Rewrite "avg" to sumCount().1 / sumCount().2
|
||||
auto new_arg1 = makeASTFunction("tupleElement", func_base, std::make_shared<ASTLiteral>(UInt8(1)));
|
||||
auto new_arg2 = makeASTFunction("tupleElement", func_base, std::make_shared<ASTLiteral>(UInt8(2)));
|
||||
func.name = "divide";
|
||||
|
Loading…
Reference in New Issue
Block a user