Skip to content

Commit 7286d0e

Browse files
authored
Merge pull request ClickHouse#80106 from Algunenano/i19311
Improve bitmap function error messages
2 parents cb8e0e6 + baa47a9 commit 7286d0e

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/Functions/FunctionsBitmap.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,14 @@ class FunctionBitmapContains : public IFunction
862862
"First argument for function {} must be a bitmap but it has type {}",
863863
getName(), arguments[0]->getName());
864864

865+
WhichDataType first_aggregate_argument(bitmap_type0->getArgumentsDataTypes()[0]);
866+
if (!first_aggregate_argument.isNativeInt() && !first_aggregate_argument.isNativeUInt())
867+
throw Exception(
868+
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
869+
"First argument for function {} must be a bitmap of an integer but it is a bitmap of {}",
870+
getName(),
871+
bitmap_type0->getArgumentsDataTypes()[0]->getName());
872+
865873
WhichDataType which(arguments[1].get());
866874
if (!which.isNativeInt() && !which.isNativeUInt())
867875
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,

tests/queries/0_stateless/03457_bitmapContains_nullable.reference

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- https://github.com/ClickHouse/ClickHouse/issues/19311
2+
WITH (SELECT groupBitmapState(number::Nullable(UInt8)) as n from numbers(1)) as n SELECT number as x, bitmapContains(n, x) FROM numbers(10); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
3+
4+
WITH
5+
men AS
6+
(
7+
SELECT
8+
toUInt32(number) AS id,
9+
mod(id, 100) AS age,
10+
mod(id, 1000) * 60 AS sal,
11+
mod(id, 60) AS nat
12+
FROM system.numbers
13+
LIMIT 10
14+
),
15+
t AS
16+
(
17+
SELECT
18+
number AS n,
19+
multiIf(n = 0, 0, n = 1, 6, n = 2, 30, NULL) AS lo,
20+
multiIf(n = 0, 5, n = 1, 29, n = 2, 99, NULL) AS hi
21+
FROM system.numbers
22+
LIMIT 3
23+
),
24+
t2 AS
25+
(
26+
SELECT
27+
toString(n) AS name,
28+
groupBitmapState(multiIf((age >= lo) AND (age <= hi), id, NULL)) AS bit_state
29+
FROM men, t
30+
GROUP BY n
31+
)
32+
SELECT
33+
name,
34+
sumIf(sal, bitmapContains(bit_state, id))
35+
FROM men, t2
36+
GROUP BY name; -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }

0 commit comments

Comments
 (0)