disable null_as_default when type is Nullable

This commit is contained in:
Amos Bird 2021-02-24 14:45:14 +08:00
parent 6946514c0b
commit abf26d4935
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 16 additions and 3 deletions

View File

@ -255,9 +255,15 @@ bool ValuesBlockInputFormat::parseExpression(IColumn & column, size_t column_idx
bool found_in_cache = false; bool found_in_cache = false;
const auto & result_type = header.getByPosition(column_idx).type; const auto & result_type = header.getByPosition(column_idx).type;
const char * delimiter = (column_idx + 1 == num_columns) ? ")" : ","; const char * delimiter = (column_idx + 1 == num_columns) ? ")" : ",";
auto structure = templates_cache.getFromCacheOrConstruct(result_type, format_settings.null_as_default, auto structure = templates_cache.getFromCacheOrConstruct(
TokenIterator(tokens), token_iterator, result_type,
ast, *context, &found_in_cache, delimiter); !result_type->isNullable() && format_settings.null_as_default,
TokenIterator(tokens),
token_iterator,
ast,
*context,
&found_in_cache,
delimiter);
templates[column_idx].emplace(structure); templates[column_idx].emplace(structure);
if (found_in_cache) if (found_in_cache)
++attempts_to_deduce_template_cached[column_idx]; ++attempts_to_deduce_template_cached[column_idx];

View File

@ -0,0 +1,2 @@
A
\N

View File

@ -0,0 +1,5 @@
drop table if exists test_num;
create table test_enum (c Nullable(Enum16('A' = 1, 'B' = 2))) engine Log;
insert into test_enum values (1), (NULL);
select * from test_enum;
drop table if exists test_num;