Merge pull request #22026 from kitaisreal/cast-to-enum-nullable-fix

Cast to enum nullable fix
This commit is contained in:
alexey-milovidov 2021-03-23 23:51:19 +03:00 committed by GitHub
commit 150a2df9df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -2798,12 +2798,16 @@ private:
auto & out_data = static_cast<typename EnumType::ColumnType &>(*res).getData();
out_data.resize(size);
auto default_enum_value = result_type.getValues().front().second;
if (nullable_col)
{
for (const auto i : ext::range(0, size))
{
if (!nullable_col->isNullAt(i))
out_data[i] = result_type.getValue(col->getDataAt(i));
else
out_data[i] = default_enum_value;
}
}
else

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
SELECT toUInt8(assumeNotNull(cast(cast(NULL, 'Nullable(String)'), 'Nullable(Enum8(\'Hello\' = 1))')));