Clickhouse: Exception for function avgArray with NULL values

Created on 6 Sep 2018  ยท  2Comments  ยท  Source: ClickHouse/ClickHouse

Trying to do such request:

SELECT avgArray([NULL, 1]);

Getting such exception:

Received exception from server (version 18.10.3):
Code: 43. DB::Exception: Received from clickhouse-server:9000, 172.17.0.2. DB::Exception: Illegal type Nullable(UInt8) of argument for aggregate function avg.

ClickHouse server version is 18.10.3.

bug

Most helpful comment

It should work.

milovidov-Pro-P30 :) SELECT avg(x) FROM (SELECT arrayJoin([1, NULL]) AS x)

SELECT avg(x)
FROM 
(
    SELECT arrayJoin([1, NULL]) AS x
) 

โ”Œโ”€avg(x)โ”€โ”
โ”‚      1 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

1 rows in set. Elapsed: 0.047 sec. 

milovidov-Pro-P30 :) SELECT avgArray(x) FROM (SELECT [1, NULL] AS x)

SELECT avgArray(x)
FROM 
(
    SELECT [1, NULL] AS x
) 

Received exception from server (version 18.12.1):
Code: 43. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Illegal type Nullable(UInt8) of argument for aggregate function avg. 

0 rows in set. Elapsed: 0.141 sec.

All 2 comments

It should work.

milovidov-Pro-P30 :) SELECT avg(x) FROM (SELECT arrayJoin([1, NULL]) AS x)

SELECT avg(x)
FROM 
(
    SELECT arrayJoin([1, NULL]) AS x
) 

โ”Œโ”€avg(x)โ”€โ”
โ”‚      1 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

1 rows in set. Elapsed: 0.047 sec. 

milovidov-Pro-P30 :) SELECT avgArray(x) FROM (SELECT [1, NULL] AS x)

SELECT avgArray(x)
FROM 
(
    SELECT [1, NULL] AS x
) 

Received exception from server (version 18.12.1):
Code: 43. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Illegal type Nullable(UInt8) of argument for aggregate function avg. 

0 rows in set. Elapsed: 0.141 sec.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

aa8808021 picture aa8808021  ยท  32Comments

I-akshay picture I-akshay  ยท  25Comments

simPod picture simPod  ยท  19Comments

manojfim picture manojfim  ยท  19Comments

aegorov05 picture aegorov05  ยท  29Comments