Merge pull request #66842 from ClickHouse/remove-with-dictionary

Remove `WithDictionary`
This commit is contained in:
Alexey Milovidov 2024-07-24 11:57:32 +00:00 committed by GitHub
commit 5a4595536e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 10 additions and 58 deletions

View File

@ -125,23 +125,6 @@ DataTypePtr DataTypeFactory::getImpl(const String & family_name_param, const AST
{ {
String family_name = getAliasToOrName(family_name_param); String family_name = getAliasToOrName(family_name_param);
if (endsWith(family_name, "WithDictionary"))
{
ASTPtr low_cardinality_params = std::make_shared<ASTExpressionList>();
String param_name = family_name.substr(0, family_name.size() - strlen("WithDictionary"));
if (parameters)
{
auto func = std::make_shared<ASTFunction>();
func->name = param_name;
func->arguments = parameters;
low_cardinality_params->children.push_back(func);
}
else
low_cardinality_params->children.push_back(std::make_shared<ASTIdentifier>(param_name));
return getImpl<nullptr_on_error>("LowCardinality", low_cardinality_params);
}
const auto * creator = findCreatorByName<nullptr_on_error>(family_name); const auto * creator = findCreatorByName<nullptr_on_error>(family_name);
if constexpr (nullptr_on_error) if constexpr (nullptr_on_error)
{ {

View File

@ -1,5 +1,5 @@
drop table if exists lc_dict_reading; drop table if exists lc_dict_reading;
create table lc_dict_reading (val UInt64, str StringWithDictionary, pat String) engine = MergeTree order by val SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; create table lc_dict_reading (val UInt64, str LowCardinality(String), pat String) engine = MergeTree order by val SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi';
insert into lc_dict_reading select number, if(number < 8192 * 4, number % 100, number) as s, s from system.numbers limit 1000000; insert into lc_dict_reading select number, if(number < 8192 * 4, number % 100, number) as s, s from system.numbers limit 1000000;
select sum(toUInt64(str)), sum(toUInt64(pat)) from lc_dict_reading where val < 8129 or val > 8192 * 4; select sum(toUInt64(str)), sum(toUInt64(pat)) from lc_dict_reading where val < 8129 or val > 8192 * 4;
drop table if exists lc_dict_reading; drop table if exists lc_dict_reading;

View File

@ -1,6 +1,6 @@
set allow_suspicious_low_cardinality_types = 1; set allow_suspicious_low_cardinality_types = 1;
drop table if exists lc_00688; drop table if exists lc_00688;
create table lc_00688 (str StringWithDictionary, val UInt8WithDictionary) engine = MergeTree order by tuple(); create table lc_00688 (str LowCardinality(String), val LowCardinality(UInt8)) engine = MergeTree order by tuple();
insert into lc_00688 values ('a', 1), ('b', 2); insert into lc_00688 values ('a', 1), ('b', 2);
select str, str in ('a', 'd') from lc_00688; select str, str in ('a', 'd') from lc_00688;
select val, val in (1, 3) from lc_00688; select val, val in (1, 3) from lc_00688;

View File

@ -1,5 +1,5 @@
drop table if exists lc_prewhere; drop table if exists lc_prewhere;
create table lc_prewhere (key UInt64, val UInt64, str StringWithDictionary, s String) engine = MergeTree order by key settings index_granularity = 8192; create table lc_prewhere (key UInt64, val UInt64, str LowCardinality(String), s String) engine = MergeTree order by key settings index_granularity = 8192;
insert into lc_prewhere select number, if(number < 10 or number > 8192 * 9, 1, 0), toString(number) as s, s from system.numbers limit 100000; insert into lc_prewhere select number, if(number < 10 or number > 8192 * 9, 1, 0), toString(number) as s, s from system.numbers limit 100000;
select sum(toUInt64(str)), sum(toUInt64(s)) from lc_prewhere prewhere val == 1; select sum(toUInt64(str)), sum(toUInt64(s)) from lc_prewhere prewhere val == 1;
drop table if exists lc_prewhere; drop table if exists lc_prewhere;

View File

@ -8,8 +8,8 @@ select 'MergeTree';
drop table if exists lc_small_dict; drop table if exists lc_small_dict;
drop table if exists lc_big_dict; drop table if exists lc_big_dict;
create table lc_small_dict (str StringWithDictionary) engine = MergeTree order by str SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; create table lc_small_dict (str LowCardinality(String)) engine = MergeTree order by str SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi';
create table lc_big_dict (str StringWithDictionary) engine = MergeTree order by str SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi'; create table lc_big_dict (str LowCardinality(String)) engine = MergeTree order by str SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi';
insert into lc_small_dict select toString(number % 1000) from system.numbers limit 1000000; insert into lc_small_dict select toString(number % 1000) from system.numbers limit 1000000;
insert into lc_big_dict select toString(number) from system.numbers limit 1000000; insert into lc_big_dict select toString(number) from system.numbers limit 1000000;

View File

@ -1,13 +1,7 @@
a a
a a
a
a
1 1
1 1
1
1
ab
ab
ab ab
ab ab
- -

View File

@ -13,56 +13,32 @@ drop table if exists lc_null_fix_str_0;
drop table if exists lc_null_fix_str_1; drop table if exists lc_null_fix_str_1;
create table lc_str_0 (str LowCardinality(String)) engine = Memory; create table lc_str_0 (str LowCardinality(String)) engine = Memory;
create table lc_str_1 (str StringWithDictionary) engine = Memory;
create table lc_null_str_0 (str LowCardinality(Nullable(String))) engine = Memory; create table lc_null_str_0 (str LowCardinality(Nullable(String))) engine = Memory;
create table lc_null_str_1 (str NullableWithDictionary(String)) engine = Memory;
create table lc_int8_0 (val LowCardinality(Int8)) engine = Memory; create table lc_int8_0 (val LowCardinality(Int8)) engine = Memory;
create table lc_int8_1 (val Int8WithDictionary) engine = Memory;
create table lc_null_int8_0 (val LowCardinality(Nullable(Int8))) engine = Memory; create table lc_null_int8_0 (val LowCardinality(Nullable(Int8))) engine = Memory;
create table lc_null_int8_1 (val NullableWithDictionary(Int8)) engine = Memory;
create table lc_fix_str_0 (str LowCardinality(FixedString(2))) engine = Memory; create table lc_fix_str_0 (str LowCardinality(FixedString(2))) engine = Memory;
create table lc_fix_str_1 (str FixedStringWithDictionary(2)) engine = Memory;
create table lc_null_fix_str_0 (str LowCardinality(Nullable(FixedString(2)))) engine = Memory; create table lc_null_fix_str_0 (str LowCardinality(Nullable(FixedString(2)))) engine = Memory;
create table lc_null_fix_str_1 (str NullableWithDictionary(FixedString(2))) engine = Memory;
insert into lc_str_0 select 'a'; insert into lc_str_0 select 'a';
insert into lc_str_1 select 'a';
insert into lc_null_str_0 select 'a'; insert into lc_null_str_0 select 'a';
insert into lc_null_str_1 select 'a';
insert into lc_int8_0 select 1; insert into lc_int8_0 select 1;
insert into lc_int8_1 select 1;
insert into lc_null_int8_0 select 1; insert into lc_null_int8_0 select 1;
insert into lc_null_int8_1 select 1;
insert into lc_fix_str_0 select 'ab'; insert into lc_fix_str_0 select 'ab';
insert into lc_fix_str_1 select 'ab';
insert into lc_null_fix_str_0 select 'ab'; insert into lc_null_fix_str_0 select 'ab';
insert into lc_null_fix_str_1 select 'ab';
select str from lc_str_0; select str from lc_str_0;
select str from lc_str_1;
select str from lc_null_str_0; select str from lc_null_str_0;
select str from lc_null_str_1;
select val from lc_int8_0; select val from lc_int8_0;
select val from lc_int8_1;
select val from lc_null_int8_0; select val from lc_null_int8_0;
select val from lc_null_int8_1;
select str from lc_fix_str_0; select str from lc_fix_str_0;
select str from lc_fix_str_1;
select str from lc_null_fix_str_0; select str from lc_null_fix_str_0;
select str from lc_null_fix_str_1;
drop table if exists lc_str_0; drop table if exists lc_str_0;
drop table if exists lc_str_1;
drop table if exists lc_null_str_0; drop table if exists lc_null_str_0;
drop table if exists lc_null_str_1;
drop table if exists lc_int8_0; drop table if exists lc_int8_0;
drop table if exists lc_int8_1;
drop table if exists lc_null_int8_0; drop table if exists lc_null_int8_0;
drop table if exists lc_null_int8_1;
drop table if exists lc_fix_str_0; drop table if exists lc_fix_str_0;
drop table if exists lc_fix_str_1;
drop table if exists lc_null_fix_str_0; drop table if exists lc_null_fix_str_0;
drop table if exists lc_null_fix_str_1;
select '-'; select '-';
SELECT toLowCardinality('a') AS s, toTypeName(s), toTypeName(length(s)) from system.one; SELECT toLowCardinality('a') AS s, toTypeName(s), toTypeName(length(s)) from system.one;
@ -73,7 +49,7 @@ select (toLowCardinality(z) as val) || 'b' from (select arrayJoin(['c', 'd']) a
select '-'; select '-';
drop table if exists lc_str_uuid; drop table if exists lc_str_uuid;
create table lc_str_uuid(str1 String, str2 LowCardinality(String), str3 StringWithDictionary) ENGINE=Memory; create table lc_str_uuid(str1 String, str2 LowCardinality(String), str3 LowCardinality(String)) ENGINE=Memory;
select toUUID(str1), toUUID(str2), toUUID(str3) from lc_str_uuid; 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; 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'); insert into lc_str_uuid values ('61f0c404-5cb3-11e7-907b-a6006ad3dba0', '61f0c404-5cb3-11e7-907b-a6006ad3dba0', '61f0c404-5cb3-11e7-907b-a6006ad3dba0');

View File

@ -1,5 +1,5 @@
drop table if exists tab_00717; drop table if exists tab_00717;
create table tab_00717 (a String, b StringWithDictionary) engine = MergeTree order by a; create table tab_00717 (a String, b LowCardinality(String)) engine = MergeTree order by a;
insert into tab_00717 values ('a_1', 'b_1'), ('a_2', 'b_2'); insert into tab_00717 values ('a_1', 'b_1'), ('a_2', 'b_2');
select count() from tab_00717; select count() from tab_00717;
select a from tab_00717 group by a order by a; select a from tab_00717 group by a order by a;

View File

@ -7,7 +7,7 @@ alter table tab_00718 modify column b UInt32;
select *, toTypeName(b) from tab_00718; select *, toTypeName(b) from tab_00718;
alter table tab_00718 modify column b LowCardinality(UInt32); alter table tab_00718 modify column b LowCardinality(UInt32);
select *, toTypeName(b) from tab_00718; select *, toTypeName(b) from tab_00718;
alter table tab_00718 modify column b StringWithDictionary; alter table tab_00718 modify column b LowCardinality(String);
select *, toTypeName(b) from tab_00718; select *, toTypeName(b) from tab_00718;
alter table tab_00718 modify column b LowCardinality(UInt32); alter table tab_00718 modify column b LowCardinality(UInt32);
select *, toTypeName(b) from tab_00718; select *, toTypeName(b) from tab_00718;

View File

@ -1,7 +1,7 @@
drop table if exists lc_00752; drop table if exists lc_00752;
drop table if exists lc_mv_00752; drop table if exists lc_mv_00752;
create table lc_00752 (str StringWithDictionary) engine = MergeTree order by tuple(); create table lc_00752 (str LowCardinality(String)) engine = MergeTree order by tuple();
insert into lc_00752 values ('a'), ('bbb'), ('ab'), ('accccc'), ('baasddas'), ('bcde'); insert into lc_00752 values ('a'), ('bbb'), ('ab'), ('accccc'), ('baasddas'), ('bcde');
@ -12,4 +12,3 @@ select * from lc_mv_00752 order by letter;
drop table if exists lc_00752; drop table if exists lc_00752;
drop table if exists lc_mv_00752; drop table if exists lc_mv_00752;

View File

@ -28,7 +28,7 @@ ORDER BY tuple();
INSERT INTO t_01411_num (num) SELECT number % 1000 FROM numbers(100000); INSERT INTO t_01411_num (num) SELECT number % 1000 FROM numbers(100000);
create table lc_dict_reading (val UInt64, str StringWithDictionary, pat String) engine = MergeTree order by val; create table lc_dict_reading (val UInt64, str LowCardinality(String), pat String) engine = MergeTree order by val;
insert into lc_dict_reading select number, if(number < 8192 * 4, number % 100, number) as s, s from system.numbers limit 100000; insert into lc_dict_reading select number, if(number < 8192 * 4, number % 100, number) as s, s from system.numbers limit 100000;
""" """