mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Fix support for complex parameters of parametric aggregate functions, #30975
This commit is contained in:
parent
f3a4163c87
commit
8b6092b321
@ -461,6 +461,7 @@ public:
|
|||||||
bool keepKey(const T &) const { return true; }
|
bool keepKey(const T &) const { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T, bool overflow, bool tuple_argument>
|
template <typename T, bool overflow, bool tuple_argument>
|
||||||
class AggregateFunctionSumMapFiltered final :
|
class AggregateFunctionSumMapFiltered final :
|
||||||
public AggregateFunctionMapBase<T,
|
public AggregateFunctionMapBase<T,
|
||||||
@ -495,14 +496,15 @@ public:
|
|||||||
"Aggregate function {} requires an Array as a parameter",
|
"Aggregate function {} requires an Array as a parameter",
|
||||||
getName());
|
getName());
|
||||||
|
|
||||||
|
this->parameters = params_;
|
||||||
|
|
||||||
keys_to_keep.reserve(keys_to_keep_values.size());
|
keys_to_keep.reserve(keys_to_keep_values.size());
|
||||||
|
|
||||||
for (const Field & f : keys_to_keep_values)
|
for (const Field & f : keys_to_keep_values)
|
||||||
keys_to_keep.emplace(f.safeGet<T>());
|
keys_to_keep.emplace(f.safeGet<T>());
|
||||||
}
|
}
|
||||||
|
|
||||||
String getName() const override
|
String getName() const override { return overflow ? "sumMapFilteredWithOverflow" : "sumMapFiltered"; }
|
||||||
{ return overflow ? "sumMapFilteredWithOverflow" : "sumMapFiltered"; }
|
|
||||||
|
|
||||||
bool keepKey(const T & key) const { return keys_to_keep.count(key); }
|
bool keepKey(const T & key) const { return keys_to_keep.count(key); }
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ String DataTypeAggregateFunction::getNameImpl(bool with_version) const
|
|||||||
if (!parameters.empty())
|
if (!parameters.empty())
|
||||||
{
|
{
|
||||||
stream << '(';
|
stream << '(';
|
||||||
for (size_t i = 0; i < parameters.size(); ++i)
|
for (size_t i = 0, size = parameters.size(); i < size; ++i)
|
||||||
{
|
{
|
||||||
if (i)
|
if (i)
|
||||||
stream << ", ";
|
stream << ", ";
|
||||||
|
@ -27,7 +27,7 @@ private:
|
|||||||
{
|
{
|
||||||
ParserNestedTable nested_parser;
|
ParserNestedTable nested_parser;
|
||||||
ParserDataType data_type_parser;
|
ParserDataType data_type_parser;
|
||||||
ParserLiteral literal_parser;
|
ParserAllCollectionsOfLiterals literal_parser;
|
||||||
|
|
||||||
const char * operators[] = {"=", "equals", nullptr};
|
const char * operators[] = {"=", "equals", nullptr};
|
||||||
ParserLeftAssociativeBinaryOperatorList enum_parser(operators, std::make_unique<ParserLiteral>());
|
ParserLeftAssociativeBinaryOperatorList enum_parser(operators, std::make_unique<ParserLiteral>());
|
||||||
@ -145,4 +145,3 @@ bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
AggregateFunction(1, sumMapFiltered([1, 2]), Array(UInt8), Array(UInt8))
|
||||||
|
02010A00000000000000020A00000000000000
|
||||||
|
02010A00000000000000020A00000000000000
|
||||||
|
([1,2],[20,20])
|
@ -0,0 +1,4 @@
|
|||||||
|
SELECT toTypeName(sumMapFilteredState([1, 2])([1, 2, 3], [10, 10, 10]));
|
||||||
|
SELECT hex(sumMapFilteredState([1, 2])([1, 2, 3], [10, 10, 10]));
|
||||||
|
SELECT hex(unhex('02010A00000000000000020A00000000000000')::AggregateFunction(1, sumMapFiltered([1, 2]), Array(UInt8), Array(UInt8)));
|
||||||
|
SELECT sumMapFilteredMerge([1, 2])(*) FROM remote('127.0.0.{1,2}', view(SELECT sumMapFilteredState([1, 2])([1, 2, 3], [10, 10, 10])));
|
Loading…
Reference in New Issue
Block a user