mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
b5cf644668
* Check projection metadata the same way we check ordinary metadata. * Allow aggregate projection to have empty PK --------- Co-authored-by: Alexander Tokmakov <tavplubix@clickhouse.com>
92 lines
3.3 KiB
SQL
92 lines
3.3 KiB
SQL
drop table if exists test;
|
|
|
|
set allow_suspicious_low_cardinality_types = 1;
|
|
|
|
CREATE TABLE test
|
|
(
|
|
`timestamp` DateTime,
|
|
`latitude` Nullable(Float32) CODEC(Gorilla, ZSTD(1)),
|
|
`longitude` Nullable(Float32) CODEC(Gorilla, ZSTD(1)),
|
|
`xxxx1` LowCardinality(UInt8),
|
|
`xxxx2` LowCardinality(Nullable(Int16)),
|
|
`xxxx3` LowCardinality(Nullable(Int16)),
|
|
`xxxx4` Nullable(Int32),
|
|
`xxxx5` LowCardinality(Nullable(Int32)),
|
|
`xxxx6` Nullable(Int32),
|
|
`xxxx7` Nullable(Int32),
|
|
`xxxx8` LowCardinality(Int32),
|
|
`xxxx9` LowCardinality(Nullable(Int16)),
|
|
`xxxx10` LowCardinality(Nullable(Int16)),
|
|
`xxxx11` LowCardinality(Nullable(Int16)),
|
|
`xxxx12` LowCardinality(String),
|
|
`xxxx13` Nullable(Float32),
|
|
`xxxx14` LowCardinality(String),
|
|
`xxxx15` LowCardinality(Nullable(String)),
|
|
`xxxx16` LowCardinality(String),
|
|
`xxxx17` LowCardinality(String),
|
|
`xxxx18` FixedString(19),
|
|
`xxxx19` FixedString(17),
|
|
`xxxx20` LowCardinality(UInt8),
|
|
`xxxx21` LowCardinality(Nullable(Int16)),
|
|
`xxxx22` LowCardinality(Nullable(Int16)),
|
|
`xxxx23` LowCardinality(Nullable(Int16)),
|
|
`xxxx24` LowCardinality(Nullable(Int16)),
|
|
`xxxx25` LowCardinality(Nullable(Int16)),
|
|
`xxxx26` LowCardinality(Nullable(Int16)),
|
|
`xxxx27` Nullable(Float32),
|
|
`xxxx28` LowCardinality(Nullable(String)),
|
|
`xxxx29` LowCardinality(String),
|
|
`xxxx30` LowCardinality(String),
|
|
`xxxx31` LowCardinality(Nullable(String)),
|
|
`xxxx32` UInt64,
|
|
PROJECTION cumsum_projection_simple
|
|
(
|
|
SELECT
|
|
xxxx1,
|
|
toStartOfInterval(timestamp, toIntervalMonth(1)),
|
|
toStartOfWeek(timestamp, 8),
|
|
toStartOfInterval(timestamp, toIntervalDay(1)),
|
|
xxxx17,
|
|
xxxx16,
|
|
xxxx14,
|
|
xxxx9,
|
|
xxxx10,
|
|
xxxx21,
|
|
xxxx22,
|
|
xxxx11,
|
|
sum(multiIf(xxxx21 IS NULL, 0, 1)),
|
|
sum(multiIf(xxxx22 IS NULL, 0, 1)),
|
|
sum(multiIf(xxxx23 IS NULL, 0, 1)),
|
|
max(toStartOfInterval(timestamp, toIntervalDay(1))),
|
|
max(CAST(CAST(toStartOfInterval(timestamp, toIntervalDay(1)), 'Nullable(DATE)'), 'Nullable(TIMESTAMP)')),
|
|
min(toStartOfInterval(timestamp, toIntervalDay(1))),
|
|
min(CAST(CAST(toStartOfInterval(timestamp, toIntervalDay(1)), 'Nullable(DATE)'), 'Nullable(TIMESTAMP)')),
|
|
count(),
|
|
sum(1),
|
|
COUNTDistinct(xxxx16),
|
|
COUNTDistinct(xxxx31),
|
|
COUNTDistinct(xxxx14),
|
|
COUNTDistinct(CAST(toStartOfInterval(timestamp, toIntervalDay(1)), 'Nullable(DATE)'))
|
|
GROUP BY
|
|
xxxx1,
|
|
toStartOfInterval(timestamp, toIntervalMonth(1)),
|
|
toStartOfWeek(timestamp, 8),
|
|
toStartOfInterval(timestamp, toIntervalDay(1)),
|
|
xxxx1,
|
|
toStartOfInterval(timestamp, toIntervalMonth(1)),
|
|
toStartOfWeek(timestamp, 8),
|
|
toStartOfInterval(timestamp, toIntervalDay(1)),
|
|
xxxx17,
|
|
xxxx16,
|
|
xxxx14,
|
|
xxxx9,
|
|
xxxx10,
|
|
xxxx21,
|
|
xxxx22,
|
|
xxxx11
|
|
)
|
|
)
|
|
ENGINE = MergeTree
|
|
PARTITION BY toYYYYMM(timestamp)
|
|
ORDER BY (xxxx17, xxxx14, xxxx16, toStartOfDay(timestamp), left(xxxx19, 10), timestamp); -- { serverError BAD_ARGUMENTS}
|