Skip to content

Commit

Permalink
Merge pull request #342 from Altinity/backports/23.8/55172_fix_partit…
Browse files Browse the repository at this point in the history
…ion_pruning_of_extra_columns_in_set

23.8 Backport of ClickHouse#55172 - Fix partition pruning of extra columns in set
  • Loading branch information
Enmk authored Dec 25, 2023
2 parents 37e99eb + 1985a21 commit 3d7b4f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Storages/MergeTree/KeyCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,14 @@ bool KeyCondition::tryPrepareSetIndex(
if (!future_set)
return false;

const auto set_types = future_set->getTypes();
size_t set_types_size = set_types.size();
size_t indexes_mapping_size = indexes_mapping.size();

/// When doing strict matches, we have to check all elements in set.
if (strict && indexes_mapping_size < set_types_size)
return false;

auto prepared_set = future_set->buildOrderedSetInplace(right_arg.getTreeContext().getQueryContext());
if (!prepared_set)
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP TABLE IF EXISTS e;

CREATE TABLE e (dt DateTime, t Int32) ENGINE = MergeTree() PARTITION BY (t, toYYYYMM(dt)) ORDER BY tuple();

INSERT INTO e SELECT toDateTime('2022-12-12 11:00:00') + number, 86 FROM numbers(10);

SELECT COUNT(*) FROM e WHERE (t, dt) IN (86, '2022-12-12 11:00:00');

DROP TABLE e;

0 comments on commit 3d7b4f9

Please sign in to comment.