Fix index analysis for set index

This commit is contained in:
Amos Bird 2021-10-31 02:03:58 +08:00
parent 77d461609c
commit b3a8ad124f
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 8 additions and 2 deletions

View File

@ -451,9 +451,9 @@ bool MergeTreeIndexConditionSet::checkASTUseless(const ASTPtr & node, bool atomi
const ASTs & args = func->arguments->children;
if (func->name == "and" || func->name == "indexHint")
return checkASTUseless(args[0], atomic) && checkASTUseless(args[1], atomic);
return std::all_of(args.begin(), args.end(), [this, atomic](const auto & arg) { return checkASTUseless(arg, atomic); });
else if (func->name == "or")
return checkASTUseless(args[0], atomic) || checkASTUseless(args[1], atomic);
return std::any_of(args.begin(), args.end(), [this, atomic](const auto & arg) { return checkASTUseless(arg, atomic); });
else if (func->name == "not")
return checkASTUseless(args[0], atomic);
else

View File

@ -0,0 +1,6 @@
drop table if exists set_index;
create table set_index (a Int32, b Int32, INDEX b_set b type set(0) granularity 1) engine MergeTree order by tuple();
insert into set_index values (1, 2);
select b from set_index where a = 1 and a = 1 and b = 1 settings force_data_skipping_indices = 'b_set', optimize_move_to_prewhere=0;