fix index analysis with tuples and IN

This commit is contained in:
Anton Popov 2022-07-31 00:38:52 +00:00
parent 24aaac59ca
commit 095e400075
3 changed files with 28 additions and 2 deletions

View File

@ -430,8 +430,9 @@ MergeTreeSetIndex::MergeTreeSetIndex(const Columns & set_elements, std::vector<K
SortDescription sort_description;
for (size_t i = 0; i < tuple_size; ++i)
{
block_to_sort.insert({ordered_set[i], nullptr, ordered_set[i]->getName()});
sort_description.emplace_back(ordered_set[i]->getName(), 1, 1);
String column_name = "_" + toString(i);
block_to_sort.insert({ordered_set[i], nullptr, column_name});
sort_description.emplace_back(column_name, 1, 1);
}
sortBlock(block_to_sort, sort_description);

View File

@ -0,0 +1,2 @@
2
2

View File

@ -0,0 +1,23 @@
DROP TABLE IF EXISTS t_in_tuple_index;
CREATE TABLE t_in_tuple_index
(
`ID` String,
`USER_ID` String,
`PLATFORM` LowCardinality(String)
)
ENGINE = MergeTree()
ORDER BY (PLATFORM, USER_ID, ID)
SETTINGS index_granularity = 2048;
INSERT INTO t_in_tuple_index VALUES ('1', 33, 'insta'), ('2', 33, 'insta');
SELECT count()
FROM t_in_tuple_index
WHERE (PLATFORM, USER_ID) IN (('insta', '33'));
SELECT count()
FROM t_in_tuple_index
WHERE (PLATFORM, USER_ID) IN (('insta', '33'), ('insta', '22'));
DROP TABLE IF EXISTS t_in_tuple_index;