DC
anyState
Size: a a a
DC
D
D
DC
select user_id, count(*) from users group by user_id
select from view where user_id = A
user_id = A
судя по explain syntax будет выполнен на шаге having. то есть сначала выполнится group by, затем уже только фильтр. DC
DC
D
K
DC
❌
exception_code: ZOK
AR
D
AM
date
Date,id
UInt64,volume
String,date
Date,id
UInt64,volume
UInt32MD
AK
CREATE TABLE source
(
a Int32,
b Int32,
c Nullable(Int32)
)
ENGINE = MergeTree
ORDER BY a
CREATE TABLE destination
(
a UInt64,
st AggregateFunction(argMax, Int32, Int32)
)
ENGINE = AggregatingMergeTree
ORDER BY a
CREATE MATERIALIZED VIEW mv TO destination AS
SELECT
a,
argMaxState(c, b) AS st
FROM source
GROUP BY a
source
работала, но на 20.8 перестала:
Conversion from AggregateFunction(argMax, Nullable(Int32), Int32) to AggregateFunction(argMax, Int32, Int32) is not supported: while converting source column st to destination column st: while pushing to view default.mv.
CREATE MATERIALIZED VIEW mv TO destination AS
SELECT
a,
argMaxState(coalesce(c, 0), b) AS st
FROM source
GROUP BY a
source
:
insert into source values (1,1,1), (1,2,null)
SELECT
a,
argMaxMerge(st)
FROM destination
GROUP BY a
┌─a─┬─argMaxMerge(st)─┐
│ 1 │ 0 │
└───┴─────────────────┘
┌─a─┬─argMaxMerge(st)─┐
│ 1 │ 1 │
└───┴─────────────────┘
D
CREATE TABLE source
(
a Int32,
b Int32,
c Nullable(Int32)
)
ENGINE = MergeTree
ORDER BY a
CREATE TABLE destination
(
a UInt64,
st AggregateFunction(argMax, Int32, Int32)
)
ENGINE = AggregatingMergeTree
ORDER BY a
CREATE MATERIALIZED VIEW mv TO destination AS
SELECT
a,
argMaxState(c, b) AS st
FROM source
GROUP BY a
source
работала, но на 20.8 перестала:
Conversion from AggregateFunction(argMax, Nullable(Int32), Int32) to AggregateFunction(argMax, Int32, Int32) is not supported: while converting source column st to destination column st: while pushing to view default.mv.
CREATE MATERIALIZED VIEW mv TO destination AS
SELECT
a,
argMaxState(coalesce(c, 0), b) AS st
FROM source
GROUP BY a
source
:
insert into source values (1,1,1), (1,2,null)
SELECT
a,
argMaxMerge(st)
FROM destination
GROUP BY a
┌─a─┬─argMaxMerge(st)─┐
│ 1 │ 0 │
└───┴─────────────────┘
┌─a─┬─argMaxMerge(st)─┐
│ 1 │ 1 │
└───┴─────────────────┘
DT
SELECT
argMax(assumeNotNull(x), y),
argMax(x, y)
FROM
(
SELECT
1 AS x,
1 AS y
UNION ALL
SELECT
NULL AS x,
2 AS y
)
Query id: f33b7565-5d19-40c1-b02c-960728e4e932
┌─argMax(assumeNotNull(x), y)─┬─argMax(x, y)─┐
│ 0 │ 1 │
└─────────────────────────────┴──────────────┘
AK
DT
AK