不能使用 Date/DateTime 作为 argMinMerge/argMaxMerge 中的参数?

Can't use Date/DateTime as arg in argMinMerge/argMaxMerge?

在一次 Afinity 网络研讨会中,他们给出了使用 argMin/argMax 聚合函数在某些 table 中查找 first/last 值的示例。他们正在使用以下 table:

CREATE TABLE cpu_last_point_idle_agg (
    created_date AggregateFunction(argMax, Date, DateTime),
...
)
Engine = AggregatingMergeTree

然后他们创建物化视图:

CREATE MATERIALIZED VIEW cpu_last_point_idle_mw
TO cpu_last_point_idle_agg
AS SELECT
    argMaxState(created_date, created_at) AS created_date,
...

最后是视图:

CREATE VIEW cpu_last_point_idle AS
SELECT
    argMaxMerge(created_date) AS created_date,
...

但是,当我尝试复制这种方法时,出现错误。

我的table:

CREATE TABLE candles.ESM20_mthly_data (
    ts DateTime Codec(Delta, LZ4),
    open AggregateFunction(argMin, DateTime, Float64),
...
)
Engine = AggregatingMergeTree
PARTITION BY toYYYYMM(ts)
ORDER BY ts
PRIMARY KEY(ts);

我的物化视图:

CREATE MATERIALIZED VIEW candles.ESM20_mthly_mw
TO candles.ESM20_mthly_data
AS SELECT
    ts,
    argMinState(ts, src.price) AS open,
...
FROM source_table as src
GROUP BY toStartOfInterval(src.ts, INTERVAL 1 month) as ts;

我的看法:

CREATE VIEW candles.ESM20_mthly 
AS SELECT
    ts,
    argMinMerge(ts) as open,
...
FROM candles.ESM20_mthly_mw
GROUP BY ts;

我收到一个错误:

Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: Illegal type DateTime('UTC') of argument for aggregate function with Merge suffix must be AggregateFunction(...). 

我尝试使用 Date 和 DateTime,结果相同。如果我翻转 arg 和值,它会起作用,但当然不会给我想要的东西。这些聚合函数是否不再支持日期?我如何让它发挥作用?

我正在使用 Connected to ClickHouse server version 20.12.3 revision 54442.

首先 argMin(a, b) -- 当 b 最小时取 a。

--AggregateFunction(argMin, DateTime, Float64),
++AggregateFunction(argMin, Float64, DateTime),

--argMinState(ts, src.price) AS open,
++argMinState(src.price,ts) AS open,

第二期是

--argMinMerge(ts) as open,
++argMinMerge(open) as final_open,