From c47f90d197e53fcf57c32d38a556cceec6eb60b7 Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Wed, 16 Nov 2022 20:50:48 +0100 Subject: [PATCH 1/9] add expression index in system.data_skipping_indices --- .../System/StorageSystemDataSkippingIndices.cpp | 11 +++++++++++ .../01917_system_data_skipping_indices.reference | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.cpp b/src/Storages/System/StorageSystemDataSkippingIndices.cpp index be04261cc4e..15561a87394 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.cpp +++ b/src/Storages/System/StorageSystemDataSkippingIndices.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -24,6 +26,7 @@ StorageSystemDataSkippingIndices::StorageSystemDataSkippingIndices(const Storage { "table", std::make_shared() }, { "name", std::make_shared() }, { "type", std::make_shared() }, + { "index_expr", std::make_shared() }, { "expr", std::make_shared() }, { "granularity", std::make_shared() }, { "data_compressed_bytes", std::make_shared() }, @@ -121,6 +124,14 @@ protected: // 'type' column if (column_mask[src_index++]) res_columns[res_index++]->insert(index.type); + // 'index_expr' column + if (column_mask[src_index++]) + { + if (auto expression = index.definition_ast->as()) + res_columns[res_index++]->insert(queryToString(expression->type->clone())); + else + res_columns[res_index++]->insertDefault(); + } // 'expr' column if (column_mask[src_index++]) { diff --git a/tests/queries/0_stateless/01917_system_data_skipping_indices.reference b/tests/queries/0_stateless/01917_system_data_skipping_indices.reference index 115d60f60cc..52bce4efebb 100644 --- a/tests/queries/0_stateless/01917_system_data_skipping_indices.reference +++ b/tests/queries/0_stateless/01917_system_data_skipping_indices.reference @@ -1,8 +1,8 @@ -default data_01917 d1_idx minmax d1 1 0 0 0 -default data_01917 d1_null_idx minmax assumeNotNull(d1_null) 1 0 0 0 -default data_01917_2 memory set frequency * length(name) 5 0 0 0 -default data_01917_2 sample_index1 minmax length(name), name 4 0 0 0 -default data_01917_2 sample_index2 ngrambf_v1 lower(name), name 4 0 0 0 +default data_01917 d1_idx minmax minmax d1 1 0 0 0 +default data_01917 d1_null_idx minmax minmax assumeNotNull(d1_null) 1 0 0 0 +default data_01917_2 memory set set(1000) frequency * length(name) 5 0 0 0 +default data_01917_2 sample_index1 minmax minmax length(name), name 4 0 0 0 +default data_01917_2 sample_index2 ngrambf_v1 ngrambf_v1(3, 256, 2, 0) lower(name), name 4 0 0 0 2 3 d1_idx From 42fb9619b0f2f74bf467a69693859b79361a6169 Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Thu, 17 Nov 2022 09:01:41 +0100 Subject: [PATCH 2/9] fix test --- .../01932_alter_index_with_order.reference | 18 +++++++++--------- ...system_data_skipping_indices_size.reference | 2 +- .../02117_show_create_table_system.reference | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/queries/0_stateless/01932_alter_index_with_order.reference b/tests/queries/0_stateless/01932_alter_index_with_order.reference index eff9ea7da0e..3df860b8ae6 100644 --- a/tests/queries/0_stateless/01932_alter_index_with_order.reference +++ b/tests/queries/0_stateless/01932_alter_index_with_order.reference @@ -1,9 +1,9 @@ -default alter_index_test index_a set a 1 0 0 0 -default alter_index_test index_b minmax b 1 0 0 0 -default alter_index_test index_c set c 2 0 0 0 -default alter_index_test index_a set a 1 0 0 0 -default alter_index_test index_d set d 1 0 0 0 -default alter_index_test index_b minmax b 1 0 0 0 -default alter_index_test index_c set c 2 0 0 0 -default alter_index_test index_a set a 1 0 0 0 -default alter_index_test index_d set d 1 0 0 0 +default alter_index_test index_a set set(0) a 1 0 0 0 +default alter_index_test index_b minmax minmax b 1 0 0 0 +default alter_index_test index_c set set(0) c 2 0 0 0 +default alter_index_test index_a set set(0) a 1 0 0 0 +default alter_index_test index_d set set(0) d 1 0 0 0 +default alter_index_test index_b minmax minmax b 1 0 0 0 +default alter_index_test index_c set set(0) c 2 0 0 0 +default alter_index_test index_a set set(0) a 1 0 0 0 +default alter_index_test index_d set set(0) d 1 0 0 0 diff --git a/tests/queries/0_stateless/02028_system_data_skipping_indices_size.reference b/tests/queries/0_stateless/02028_system_data_skipping_indices_size.reference index d0378511850..e455643c01e 100644 --- a/tests/queries/0_stateless/02028_system_data_skipping_indices_size.reference +++ b/tests/queries/0_stateless/02028_system_data_skipping_indices_size.reference @@ -1 +1 @@ -default test_table value_index minmax value 1 38 12 24 +default test_table value_index minmax minmax value 1 38 12 24 diff --git a/tests/queries/0_stateless/02117_show_create_table_system.reference b/tests/queries/0_stateless/02117_show_create_table_system.reference index 7a0c383b3fb..cc1cd214340 100644 --- a/tests/queries/0_stateless/02117_show_create_table_system.reference +++ b/tests/queries/0_stateless/02117_show_create_table_system.reference @@ -106,6 +106,7 @@ CREATE TABLE system.data_skipping_indices `table` String, `name` String, `type` String, + `index_expr` String, `expr` String, `granularity` UInt64, `data_compressed_bytes` UInt64, From 81ca8e91e600b6f56255b9f32ce17f65ec244aac Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 20 Nov 2022 14:27:52 +0300 Subject: [PATCH 3/9] Update StorageSystemDataSkippingIndices.cpp --- src/Storages/System/StorageSystemDataSkippingIndices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.cpp b/src/Storages/System/StorageSystemDataSkippingIndices.cpp index 15561a87394..7040eefd397 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.cpp +++ b/src/Storages/System/StorageSystemDataSkippingIndices.cpp @@ -127,7 +127,7 @@ protected: // 'index_expr' column if (column_mask[src_index++]) { - if (auto expression = index.definition_ast->as()) + if (auto * expression = index.definition_ast->as()) res_columns[res_index++]->insert(queryToString(expression->type->clone())); else res_columns[res_index++]->insertDefault(); From 702768469b23dff890b8970a09b4013cc1c9ab66 Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Mon, 21 Nov 2022 09:04:44 +0100 Subject: [PATCH 4/9] cosmetic --- src/Storages/System/StorageSystemDataSkippingIndices.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.cpp b/src/Storages/System/StorageSystemDataSkippingIndices.cpp index 15561a87394..ccb52e9a23a 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.cpp +++ b/src/Storages/System/StorageSystemDataSkippingIndices.cpp @@ -26,7 +26,7 @@ StorageSystemDataSkippingIndices::StorageSystemDataSkippingIndices(const Storage { "table", std::make_shared() }, { "name", std::make_shared() }, { "type", std::make_shared() }, - { "index_expr", std::make_shared() }, + { "type_full", std::make_shared() }, { "expr", std::make_shared() }, { "granularity", std::make_shared() }, { "data_compressed_bytes", std::make_shared() }, @@ -124,7 +124,7 @@ protected: // 'type' column if (column_mask[src_index++]) res_columns[res_index++]->insert(index.type); - // 'index_expr' column + // 'type_full' column if (column_mask[src_index++]) { if (auto expression = index.definition_ast->as()) From 9ecda9f45c911047e04e8a089741a19ee49fe16a Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Mon, 21 Nov 2022 11:58:48 +0100 Subject: [PATCH 5/9] fix test --- .../0_stateless/02117_show_create_table_system.reference | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/queries/0_stateless/02117_show_create_table_system.reference b/tests/queries/0_stateless/02117_show_create_table_system.reference index a0b67c92017..2561155b71e 100644 --- a/tests/queries/0_stateless/02117_show_create_table_system.reference +++ b/tests/queries/0_stateless/02117_show_create_table_system.reference @@ -106,7 +106,7 @@ CREATE TABLE system.data_skipping_indices `table` String, `name` String, `type` String, - `index_expr` String, + `type_full` String, `expr` String, `granularity` UInt64, `data_compressed_bytes` UInt64, From c1283a6bb516dac29df166276c48ed17c3787b42 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 22 Nov 2022 22:17:20 +0300 Subject: [PATCH 6/9] Update StorageSystemDataSkippingIndices.cpp --- src/Storages/System/StorageSystemDataSkippingIndices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.cpp b/src/Storages/System/StorageSystemDataSkippingIndices.cpp index aa0f186b56a..d2d0e69505d 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.cpp +++ b/src/Storages/System/StorageSystemDataSkippingIndices.cpp @@ -128,7 +128,7 @@ protected: if (column_mask[src_index++]) { if (auto * expression = index.definition_ast->as()) - res_columns[res_index++]->insert(queryToString(expression->type->clone())); + res_columns[res_index++]->insert(queryToString(expression->type)); else res_columns[res_index++]->insertDefault(); } From a7a3bc4803a1b47e532690ef34747efdae703da0 Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Wed, 23 Nov 2022 12:57:09 +0100 Subject: [PATCH 7/9] queryToString who can accept raw pointer as well --- src/Parsers/queryToString.cpp | 5 +++++ src/Parsers/queryToString.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Parsers/queryToString.cpp b/src/Parsers/queryToString.cpp index 9721aa1f128..30a38294d43 100644 --- a/src/Parsers/queryToString.cpp +++ b/src/Parsers/queryToString.cpp @@ -8,6 +8,11 @@ namespace DB return queryToString(*query); } + String queryToString(const IAST * query) + { + return queryToString(*query); + } + String queryToString(const IAST & query) { return serializeAST(query); diff --git a/src/Parsers/queryToString.h b/src/Parsers/queryToString.h index 873de218293..7e4dd5da707 100644 --- a/src/Parsers/queryToString.h +++ b/src/Parsers/queryToString.h @@ -5,5 +5,6 @@ namespace DB { String queryToString(const ASTPtr & query); + String queryToString(const IAST * query); String queryToString(const IAST & query); } From 58c54226925299e54e67322e72a49e2e9720f304 Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Thu, 24 Nov 2022 10:19:04 +0100 Subject: [PATCH 8/9] cosmetic --- src/Parsers/queryToString.cpp | 5 ----- src/Parsers/queryToString.h | 1 - src/Storages/System/StorageSystemDataSkippingIndices.cpp | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Parsers/queryToString.cpp b/src/Parsers/queryToString.cpp index 30a38294d43..9721aa1f128 100644 --- a/src/Parsers/queryToString.cpp +++ b/src/Parsers/queryToString.cpp @@ -8,11 +8,6 @@ namespace DB return queryToString(*query); } - String queryToString(const IAST * query) - { - return queryToString(*query); - } - String queryToString(const IAST & query) { return serializeAST(query); diff --git a/src/Parsers/queryToString.h b/src/Parsers/queryToString.h index 7e4dd5da707..873de218293 100644 --- a/src/Parsers/queryToString.h +++ b/src/Parsers/queryToString.h @@ -5,6 +5,5 @@ namespace DB { String queryToString(const ASTPtr & query); - String queryToString(const IAST * query); String queryToString(const IAST & query); } diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.cpp b/src/Storages/System/StorageSystemDataSkippingIndices.cpp index d2d0e69505d..96cd9ab0b32 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.cpp +++ b/src/Storages/System/StorageSystemDataSkippingIndices.cpp @@ -128,7 +128,7 @@ protected: if (column_mask[src_index++]) { if (auto * expression = index.definition_ast->as()) - res_columns[res_index++]->insert(queryToString(expression->type)); + res_columns[res_index++]->insert(queryToString(*expression->type)); else res_columns[res_index++]->insertDefault(); } From a2c894bcfdfda83d3f6883a8b0bfaffe1dcba616 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 26 Nov 2022 01:02:29 +0300 Subject: [PATCH 9/9] Just in case --- src/Storages/System/StorageSystemDataSkippingIndices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.cpp b/src/Storages/System/StorageSystemDataSkippingIndices.cpp index 96cd9ab0b32..2649cf71182 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.cpp +++ b/src/Storages/System/StorageSystemDataSkippingIndices.cpp @@ -127,7 +127,7 @@ protected: // 'type_full' column if (column_mask[src_index++]) { - if (auto * expression = index.definition_ast->as()) + if (auto * expression = index.definition_ast->as(); expression && expression->type) res_columns[res_index++]->insert(queryToString(*expression->type)); else res_columns[res_index++]->insertDefault();