sumMap function discrepancy between local mode and server mode

43 views
Skip to first unread message

dyang

unread,
Dec 14, 2021, 5:15:30 AM12/14/21
to ClickHouse
Hi , I just start some evaluation work on ClickHouse  .  When I created a table 
and try to apply sumMap on ./clickhouse local  mode  as below , everything works fine.

CREATE TABLE session_hourly
(
    `CustomerId` UInt32,
    `Time` DateTime,
    `PlayMinutes` Array(UInt8)
)
ENGINE = MergeTree
ORDER BY CustomerId



INSERT INTO session_hourly VALUES (1,'2021-12-08 01:00:00',[3,5,7,9,10])

INSERT INTO session_hourly VALUES (2,'2021-12-08 01:00:00',[3,5,7,8,9])

INSERT INTO session_hourly VALUES (3,'2021-12-08 02:00:00',[3,5,7,8,9])


SELECT
    Time,
    sumMap(cast(arrayMap(x -> (x, 1), PlayMinutes), 'Map(UInt8,UInt8)')) AS smap
FROM session_hourly
GROUP BY Time


┌────────────────Time─┬─smap───────────────────────┐
│ 2021-12-08 01:00:00 │ {3:2,5:2,7:2,8:1,9:2,10:1} │
│ 2021-12-08 02:00:00 │ {3:1,5:1,7:1,8:1,9:1}      │
└─────────────────────┴────────────────────────────┘

everything works good  so I can  convert an Array to Map and apply sumMap on it.



But when I post exactly the same query with the same binary (start with cmd clickhouse-client)
Got the error msg : Received exception from server (version 21.11.5):
Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: When function sumMap gets one argument it must be a tuple. (ILLEGAL_TYPE_OF_ARGUMENT)


So , does this kind of discrepancy is expected between  local mode and server mode or maybe it's a bug?

Thanks!





Denis Zhuravlev

unread,
Dec 14, 2021, 8:08:36 AM12/14/21
to ClickHouse
Locally you use functionality which will be available in the next release 21.12.

in 21.11.5 arrayMap has no relation to Map datatype, because arrayMap == map of Arrays but starting from 21.12 it will change.

dyang

unread,
Dec 14, 2021, 9:51:36 PM12/14/21
to ClickHouse
So this kind of usage should be okay soon . thanks!
Reply all
Reply to author
Forward
0 new messages