Merge pull request #43308 from YiuRULE/gt/add_expression

add expression index in system.data_skipping_indices
This commit is contained in:
Alexey Milovidov 2022-12-09 05:02:27 +03:00 committed by GitHub
commit b98bc53d35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 15 deletions

View File

@ -7,6 +7,8 @@
#include <Storages/VirtualColumnUtils.h>
#include <Interpreters/Context.h>
#include <Interpreters/DatabaseCatalog.h>
#include <Parsers/ASTIndexDeclaration.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/queryToString.h>
#include <Processors/ISource.h>
#include <QueryPipeline/Pipe.h>
@ -24,6 +26,7 @@ StorageSystemDataSkippingIndices::StorageSystemDataSkippingIndices(const Storage
{ "table", std::make_shared<DataTypeString>() },
{ "name", std::make_shared<DataTypeString>() },
{ "type", std::make_shared<DataTypeString>() },
{ "type_full", std::make_shared<DataTypeString>() },
{ "expr", std::make_shared<DataTypeString>() },
{ "granularity", std::make_shared<DataTypeUInt64>() },
{ "data_compressed_bytes", std::make_shared<DataTypeUInt64>() },
@ -121,6 +124,14 @@ protected:
// 'type' column
if (column_mask[src_index++])
res_columns[res_index++]->insert(index.type);
// 'type_full' column
if (column_mask[src_index++])
{
if (auto * expression = index.definition_ast->as<ASTIndexDeclaration>(); expression && expression->type)
res_columns[res_index++]->insert(queryToString(*expression->type));
else
res_columns[res_index++]->insertDefault();
}
// 'expr' column
if (column_mask[src_index++])
{

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -104,6 +104,7 @@ CREATE TABLE system.data_skipping_indices
`table` String,
`name` String,
`type` String,
`type_full` String,
`expr` String,
`granularity` UInt64,
`data_compressed_bytes` UInt64,