Merge pull request #54449 from azat/parts-prune-indexHint

Fix filtering parts with indexHint for non analyzer
This commit is contained in:
Kruglov Pavel 2023-09-19 19:15:41 +02:00 committed by GitHub
commit d555fdffa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 1 deletions

View File

@ -1346,7 +1346,10 @@ static void buildIndexes(
}
/// TODO Support row_policy_filter and additional_filters
indexes->part_values = MergeTreeDataSelectExecutor::filterPartsByVirtualColumns(data, parts, filter_actions_dag, context);
if (settings.allow_experimental_analyzer)
indexes->part_values = MergeTreeDataSelectExecutor::filterPartsByVirtualColumns(data, parts, filter_actions_dag, context);
else
indexes->part_values = MergeTreeDataSelectExecutor::filterPartsByVirtualColumns(data, parts, query_info.query, context);
indexes->use_skip_indexes = settings.use_skip_indexes;
bool final = query_info.isFinal();

View File

@ -815,6 +815,9 @@ std::optional<std::unordered_set<String>> MergeTreeDataSelectExecutor::filterPar
ASTPtr expression_ast;
auto virtual_columns_block = data.getBlockWithVirtualPartColumns(parts, true /* one_part */);
if (virtual_columns_block.rows() == 0)
return {};
// Generate valid expressions for filtering
VirtualColumnUtils::prepareFilterBlockWithQuery(query, context, virtual_columns_block, expression_ast);

View File

@ -54,6 +54,7 @@
01710_projection_additional_filters
01721_join_implicit_cast_long
01739_index_hint
02880_indexHint__partition_id
01747_join_view_filter_dictionary
01748_partition_id_pruning
01756_optimize_skip_unused_shards_rewrite_in

View File

@ -0,0 +1,9 @@
-- { echoOn }
select * from data prewhere indexHint(_partition_id = '1');
1
select count() from data prewhere indexHint(_partition_id = '1');
1
select * from data where indexHint(_partition_id = '1');
1
select count() from data where indexHint(_partition_id = '1');
1

View File

@ -0,0 +1,9 @@
drop table if exists data;
create table data (part Int) engine=MergeTree() order by tuple() partition by part;
insert into data values (1)(2);
-- { echoOn }
select * from data prewhere indexHint(_partition_id = '1');
select count() from data prewhere indexHint(_partition_id = '1');
select * from data where indexHint(_partition_id = '1');
select count() from data where indexHint(_partition_id = '1');