mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Fix for recursive tuples in MergeTreeWhereOptimizer
This commit is contained in:
parent
23ce41e3bb
commit
7444d64156
@ -158,7 +158,7 @@ bool MergeTreeWhereOptimizer::tryAnalyzeTuple(Conditions & res, const ASTFunctio
|
||||
else if (const auto * child_ident = child->as<ASTIdentifier>())
|
||||
fetch_sign_column = std::make_shared<ASTIdentifier>(child_ident->name());
|
||||
else
|
||||
return false;
|
||||
continue;
|
||||
|
||||
ASTPtr fetch_sign_value = std::make_shared<ASTLiteral>(tuple_lit.at(i));
|
||||
ASTPtr func_node = makeASTFunction("equals", fetch_sign_column, fetch_sign_value);
|
||||
|
@ -3,3 +3,7 @@
|
||||
1 A 2021-01-01
|
||||
1 A 2021-01-01
|
||||
1 A 2021-01-01
|
||||
1 A 2021-01-01
|
||||
1 A 2021-01-01
|
||||
1 A 2021-01-01
|
||||
1 A 2021-01-01
|
||||
|
@ -2,15 +2,21 @@ DROP TABLE IF EXISTS test_tuple_filter;
|
||||
|
||||
CREATE TABLE test_tuple_filter (id UInt32, value String, log_date Date) Engine=MergeTree() ORDER BY id PARTITION BY log_date SETTINGS index_granularity = 3;
|
||||
|
||||
INSERT INTO test_tuple_filter VALUES (1, 'A','2021-01-01'),(2,'B','2021-01-01'),(3,'C','2021-01-01'),(4,'D','2021-01-02'),(5,'E','2021-01-02');
|
||||
INSERT INTO test_tuple_filter VALUES (1,'A','2021-01-01'),(2,'B','2021-01-01'),(3,'C','2021-01-01'),(4,'D','2021-01-02'),(5,'E','2021-01-02');
|
||||
|
||||
SET force_primary_key = 1;
|
||||
|
||||
SELECT * FROM test_tuple_filter WHERE (id, value) = (1, 'A');
|
||||
SELECT * FROM test_tuple_filter WHERE (1, 'A') = (id, value);
|
||||
SELECT * FROM test_tuple_filter WHERE (id, value) = (1, 'A') AND (id, log_date) = (1, '2021-01-01');
|
||||
SELECT * FROM test_tuple_filter WHERE ((id, value), id * 2) = ((1, 'A'), 2);
|
||||
SELECT * FROM test_tuple_filter WHERE ((id, value), log_date) = ((1, 'A'), '2021-01-01');
|
||||
SELECT * FROM test_tuple_filter WHERE (1, (1, (1, (1, (id, value))))) = (1, (1, (1, (1, (1, 'A')))));
|
||||
|
||||
-- not implemented yet
|
||||
SELECT * FROM test_tuple_filter WHERE (1, value) = (id, 'A'); -- { serverError INDEX_NOT_USED }
|
||||
SELECT * FROM test_tuple_filter WHERE (1, (1, (1, (1, tuple(id))))) = (1, (1, (1, (1, tuple(1))))); -- { serverError INDEX_NOT_USED }
|
||||
SELECT * FROM test_tuple_filter WHERE ((id, value), tuple(log_date)) = ((1, 'A'), tuple('2021-01-01')); -- { serverError INDEX_NOT_USED }
|
||||
|
||||
SET force_index_by_date = 1;
|
||||
SET force_primary_key = 0;
|
||||
@ -21,6 +27,7 @@ SET force_primary_key = 0;
|
||||
|
||||
SELECT * FROM test_tuple_filter WHERE (1, value) = (id, 'A');
|
||||
SELECT * FROM test_tuple_filter WHERE tuple(id) = tuple(1);
|
||||
|
||||
SELECT * FROM test_tuple_filter WHERE (log_date, value) = tuple('2021-01-01'); -- { serverError 43 }
|
||||
SELECT * FROM test_tuple_filter WHERE (id, value) = tuple(1); -- { serverError 43 }
|
||||
SELECT * FROM test_tuple_filter WHERE tuple(id, value) = tuple(value, id); -- { serverError 386 }
|
||||
|
Loading…
Reference in New Issue
Block a user