Fix Nullable String to Enum conversion.

This commit is contained in:
Amos Bird 2020-09-07 15:24:27 +08:00
parent fbf06f9858
commit 4c3c1cdaf3
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 14 additions and 3 deletions

View File

@ -2260,9 +2260,7 @@ private:
size_t nullable_pos = block.columns() - 1;
nullable_col = typeid_cast<const ColumnNullable *>(block.getByPosition(nullable_pos).column.get());
if (!nullable_col)
throw Exception("Last column should be ColumnNullable", ErrorCodes::LOGICAL_ERROR);
if (col && nullable_col->size() != col->size())
if (col && nullable_col && nullable_col->size() != col->size())
throw Exception("ColumnNullable is not compatible with original", ErrorCodes::LOGICAL_ERROR);
}

View File

@ -0,0 +1 @@
hello

View File

@ -0,0 +1,12 @@
DROP TABLE IF EXISTS t_enum;
DROP TABLE IF EXISTS t_source;
CREATE TABLE t_enum(x Enum8('hello' = 1, 'world' = 2)) ENGINE = TinyLog;
CREATE TABLE t_source(x Nullable(String)) ENGINE = TinyLog;
INSERT INTO t_source (x) VALUES ('hello');
INSERT INTO t_enum(x) SELECT x from t_source WHERE x in ('hello', 'world');
SELECT * FROM t_enum;
DROP TABLE IF EXISTS t_enum;
DROP TABLE IF EXISTS t_source;