Fix argMin/argMax combinator state

This commit is contained in:
Raúl Marín 2024-04-17 01:31:40 +01:00
parent 7c63d99625
commit 1c0d104b48
3 changed files with 36 additions and 2 deletions

View File

@ -68,9 +68,9 @@ public:
String getName() const override
{
if constexpr (isMin)
return "ArgMin";
return nested_function->getName() + "ArgMin";
else
return "ArgMax";
return nested_function->getName() + "ArgMax";
}
bool isState() const override { return nested_function->isState(); }

View File

@ -0,0 +1,12 @@
AggregateFunction(sumArgMin, UInt64, UInt64)
54
0 45
1 46
2 47
3 48
4 49
5 50
6 51
7 52
8 53
9 54

View File

@ -0,0 +1,22 @@
SELECT toTypeName(sumArgMinState(number, number)) FROM numbers(1);
SELECT sumArgMinState(number, number) AS a FROM numbers(3) FORMAT Null;
DROP TABLE IF EXISTS argmax_comb;
CREATE TABLE argmax_comb(
id UInt64,
state AggregateFunction(avgArgMax, Float64, UInt64)
)
ENGINE=MergeTree() ORDER BY tuple();
INSERT INTO argmax_comb
SELECT
CAST(number % 10, 'UInt64') AS id,
avgArgMaxState(CAST(number, 'Float64'), id)
FROM numbers(100)
GROUP BY id;
SELECT avgArgMaxMerge(state) FROM argmax_comb;
SELECT
id,
avgArgMaxMerge(state)
FROM argmax_comb
GROUP BY id
ORDER BY id ASC;