ClickHouse / ClickHouse/ClickHouse

Unexpected result: dictionary with not nullable attribute + OrDefault Null

Open
#53,654 2 comments 0 reactions 0 assignees View on GitHub
comp-dictionary external unexpected behaviour
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

```sql
create table price (key UInt64, price Float64) Engine=Memory
as
select 1, 100;

CREATE DICTIONARY test( key Int64, price Float64 default 0)
PRIMARY KEY key
SOURCE(Clickhouse(table price))
LIFETIME(0)
LAYOUT(Flat);

select key,
dictGetFloat64('test', 'price', key ) A,
dictGetFloat64OrDefault('test', 'price', key, 999) B,
dictGetFloat64OrDefault('test', 'price', key, Null) C
from (select arrayJoin([1,2]) key)
format PrettyCompactMonoBlock;
┌─key─┬───A─┬───B─┬─C────┐
│ 1 │ 100 │ 100 │ ᴺᵁᴸᴸ │ -- expected 100
│ 2 │ 0 │ 999 │ ᴺᵁᴸᴸ │
└─────┴─────┴─────┴──────┘
```

https://fiddle.clickhouse.com/188a3143-d0d3-4d15-ab38-3cda22f81509

also unexpected:
```
select key,
dictGetOrDefault('test', 'price', key, Null) C
from (select arrayJoin([1,2]) key)
format PrettyCompactMonoBlock;

DB::Exception: Cannot convert NULL to a non-nullable type: while executing
CANNOT_CONVERT_TYPE
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.