Fix filtering by tuple (some conditions was lost during analyzing)

Fixes: #29281
Fixes: test_cluster_copier/test_three_nodes.py::test
This commit is contained in:
Azat Khuzhin 2021-10-10 22:23:05 +03:00
parent a95c28ec4b
commit 6c33eaee32
3 changed files with 7 additions and 3 deletions

View File

@ -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
continue;
return false;
ASTPtr fetch_sign_value = std::make_shared<ASTLiteral>(tuple_lit.at(i));
ASTPtr func_node = makeASTFunction("equals", fetch_sign_column, fetch_sign_value);

View File

@ -6,4 +6,3 @@
1 A 2021-01-01
1 A 2021-01-01
1 A 2021-01-01
1 A 2021-01-01

View File

@ -11,7 +11,12 @@ 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 supported functions (concat) do not lost
SELECT * FROM test_tuple_filter WHERE (id, value, value||'foo') = ('1', 'A', 'A');
-- Condition fully moved to PREWHERE and such conditions does not supported yet.
SELECT * FROM test_tuple_filter WHERE (1, (1, (1, (1, (id, value))))) = (1, (1, (1, (1, (1, 'A'))))); -- { serverError INDEX_NOT_USED }
-- not implemented yet
SELECT * FROM test_tuple_filter WHERE (1, value) = (id, 'A'); -- { serverError INDEX_NOT_USED }