From 78b0b9b4fb6d69a794b878f68557b69cfc1c2c11 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Fri, 18 Dec 2020 16:10:54 +0800 Subject: [PATCH] fix enum int keycondition --- src/DataTypes/getLeastSupertype.cpp | 5 +++-- .../0_stateless/01605_key_condition_enum_int.reference | 1 + tests/queries/0_stateless/01605_key_condition_enum_int.sql | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/01605_key_condition_enum_int.reference create mode 100644 tests/queries/0_stateless/01605_key_condition_enum_int.sql diff --git a/src/DataTypes/getLeastSupertype.cpp b/src/DataTypes/getLeastSupertype.cpp index 0d2d3e66200..da0e2ed8ce4 100644 --- a/src/DataTypes/getLeastSupertype.cpp +++ b/src/DataTypes/getLeastSupertype.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -360,9 +361,9 @@ DataTypePtr getLeastSupertype(const DataTypes & types) maximize(max_bits_of_unsigned_integer, 64); else if (typeid_cast(type.get())) maximize(max_bits_of_unsigned_integer, 256); - else if (typeid_cast(type.get())) + else if (typeid_cast(type.get()) || typeid_cast(type.get())) maximize(max_bits_of_signed_integer, 8); - else if (typeid_cast(type.get())) + else if (typeid_cast(type.get()) || typeid_cast(type.get())) maximize(max_bits_of_signed_integer, 16); else if (typeid_cast(type.get())) maximize(max_bits_of_signed_integer, 32); diff --git a/tests/queries/0_stateless/01605_key_condition_enum_int.reference b/tests/queries/0_stateless/01605_key_condition_enum_int.reference new file mode 100644 index 00000000000..5626abf0f72 --- /dev/null +++ b/tests/queries/0_stateless/01605_key_condition_enum_int.reference @@ -0,0 +1 @@ +one diff --git a/tests/queries/0_stateless/01605_key_condition_enum_int.sql b/tests/queries/0_stateless/01605_key_condition_enum_int.sql new file mode 100644 index 00000000000..e6e43d8e859 --- /dev/null +++ b/tests/queries/0_stateless/01605_key_condition_enum_int.sql @@ -0,0 +1,4 @@ +drop table if exists enum; +create table enum engine MergeTree order by enum as select cast(1, 'Enum8(\'zero\'=0, \'one\'=1)') AS enum; +select * from enum where enum = 1; +drop table if exists enum;