diff --git a/src/DataTypes/DataTypeLowCardinality.cpp b/src/DataTypes/DataTypeLowCardinality.cpp index a433d39c561..9614c150c7d 100644 --- a/src/DataTypes/DataTypeLowCardinality.cpp +++ b/src/DataTypes/DataTypeLowCardinality.cpp @@ -885,15 +885,17 @@ MutableColumnUniquePtr DataTypeLowCardinality::createColumnUniqueImpl(const IDat if (const auto * nullable_type = typeid_cast(&keys_type)) type = nullable_type->getNestedType().get(); - if (isString(type)) + WhichDataType which(type); + + if (which.isString()) return creator(static_cast(nullptr)); - if (isFixedString(type)) + else if (which.isFixedString()) return creator(static_cast(nullptr)); - if (typeid_cast(type)) + else if (which.isDate()) return creator(static_cast *>(nullptr)); - if (typeid_cast(type)) + else if (which.isDateTime()) return creator(static_cast *>(nullptr)); - if (isColumnedAsNumber(type)) + else if (which.isInt() || which.isUInt() || which.isFloat()) { MutableColumnUniquePtr column; TypeListNativeNumbers::forEach(CreateColumnVector(column, *type, creator)); diff --git a/src/DataTypes/DataTypeUUID.h b/src/DataTypes/DataTypeUUID.h index e9f1d22325b..6290d05cc3b 100644 --- a/src/DataTypes/DataTypeUUID.h +++ b/src/DataTypes/DataTypeUUID.h @@ -31,6 +31,7 @@ public: bool canBeUsedInBitOperations() const override { return true; } bool canBeInsideNullable() const override { return true; } + bool canBeInsideLowCardinality() const override { return false; } bool canBePromoted() const override { return false; } }; diff --git a/tests/queries/0_stateless/00688_low_cardinality_syntax.reference b/tests/queries/0_stateless/00688_low_cardinality_syntax.reference index 035402c889d..ca27069a7df 100644 --- a/tests/queries/0_stateless/00688_low_cardinality_syntax.reference +++ b/tests/queries/0_stateless/00688_low_cardinality_syntax.reference @@ -18,3 +18,6 @@ c d cb db +- +61f0c404-5cb3-11e7-907b-a6006ad3dba0 61f0c404-5cb3-11e7-907b-a6006ad3dba0 61f0c404-5cb3-11e7-907b-a6006ad3dba0 +\N \N \N diff --git a/tests/queries/0_stateless/00688_low_cardinality_syntax.sql b/tests/queries/0_stateless/00688_low_cardinality_syntax.sql index 98d7b7f5f8a..3ca7b482b84 100644 --- a/tests/queries/0_stateless/00688_low_cardinality_syntax.sql +++ b/tests/queries/0_stateless/00688_low_cardinality_syntax.sql @@ -71,3 +71,12 @@ select (toLowCardinality('a') as val) || 'b' group by val; select toLowCardinality(z) as val from (select arrayJoin(['c', 'd']) as z) group by val; select (toLowCardinality(z) as val) || 'b' from (select arrayJoin(['c', 'd']) as z) group by val; +select '-'; +drop table if exists lc_str_uuid; +create table lc_str_uuid(str1 String, str2 LowCardinality(String), str3 StringWithDictionary) ENGINE=Memory; +select toUUID(str1), toUUID(str2), toUUID(str3) from lc_str_uuid; +select toUUID(str1, '', NULL), toUUID(str2, '', NULL), toUUID(str3, '', NULL) from lc_str_uuid; +insert into lc_str_uuid values ('61f0c404-5cb3-11e7-907b-a6006ad3dba0', '61f0c404-5cb3-11e7-907b-a6006ad3dba0', '61f0c404-5cb3-11e7-907b-a6006ad3dba0'); +select toUUID(str1), toUUID(str2), toUUID(str3) from lc_str_uuid; +select toUUID(str1, '', NULL), toUUID(str2, '', NULL), toUUID(str3, '', NULL) from lc_str_uuid; +drop table if exists lc_str_uuid;