ClickHouse/tests/queries/0_stateless/02053_INSERT_SELECT_MATERIALIZED.sql
Azat Khuzhin a063097fdf Fix INSERT SELECT incorrectly fills MATERIALIZED column based of Nullable column
Required columns of the default expression should not be converted to NULL,
since this map value to default and MATERIALIZED values will not work.

Consider the following structure:
- A Nullable(Int64)
- X Int64 materialized coalesce(A, -1)

With recursive_null_as_default=true you will get:

    _CAST(coalesce(A, -1), 'Int64') AS X, NULL AS A

And this will ignore default expression.

Fixes: #23524 (Cc: @kssenii)
Fixes: #29729 (Cc: @tavplubix)
Backport: 21.7+
2021-10-15 01:36:09 +03:00

7 lines
369 B
SQL

-- Test from https://github.com/ClickHouse/ClickHouse/issues/29729
create table data_02053 (id Int64, A Nullable(Int64), X Int64 materialized coalesce(A, -1)) engine=MergeTree order by id;
insert into data_02053 values (1, 42);
-- Due to insert_null_as_default A became Null and X became -1
insert into data_02053 select 1, 42;
select *, X from data_02053 order by id;