mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Only RIGHT JOINs test
This commit is contained in:
parent
e1331977b5
commit
752dfead2c
@ -659,7 +659,7 @@ std::unique_ptr<ExpressionStep> createComputeAliasColumnsStep(
|
||||
}
|
||||
|
||||
JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expression,
|
||||
const QueryNode & parent_query_node,
|
||||
[[maybe_unused]] const QueryNode & parent_query_node,
|
||||
const SelectQueryInfo & select_query_info,
|
||||
const SelectQueryOptions & select_query_options,
|
||||
PlannerContextPtr & planner_context,
|
||||
@ -958,6 +958,14 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres
|
||||
return true;
|
||||
};
|
||||
|
||||
LOG_DEBUG(
|
||||
getLogger(__PRETTY_FUNCTION__),
|
||||
"parallel_replicas_node={} parent_query_node={}",
|
||||
UInt64(planner_context->getGlobalPlannerContext()->parallel_replicas_node),
|
||||
UInt64(&parent_query_node));
|
||||
|
||||
// const JoinNode * table_join_node = parent_query_node.getJoinTree()->as<JoinNode>();
|
||||
|
||||
/// query_plan can be empty if there is nothing to read
|
||||
if (query_plan.isInitialized() && parallel_replicas_enabled_for_storage(storage, settings))
|
||||
{
|
||||
@ -984,9 +992,10 @@ JoinTreeQueryPlan buildQueryPlanForTableExpression(QueryTreeNodePtr table_expres
|
||||
}
|
||||
}
|
||||
else if (
|
||||
ClusterProxy::canUseParallelReplicasOnInitiator(query_context)
|
||||
&& planner_context->getGlobalPlannerContext()->parallel_replicas_node
|
||||
&& planner_context->getGlobalPlannerContext()->parallel_replicas_node == &parent_query_node)
|
||||
ClusterProxy::canUseParallelReplicasOnInitiator(query_context))
|
||||
// && (!table_join_node
|
||||
// || (table_join_node && planner_context->getGlobalPlannerContext()->parallel_replicas_node
|
||||
// && planner_context->getGlobalPlannerContext()->parallel_replicas_node == &parent_query_node)))
|
||||
{
|
||||
// (1) find read step
|
||||
QueryPlan::Node * node = query_plan.getRootNode();
|
||||
|
@ -265,11 +265,17 @@ const QueryNode * findQueryForParallelReplicas(const QueryTreeNodePtr & query_tr
|
||||
auto stack = getSupportingParallelReplicasQuery(query_tree_node.get());
|
||||
/// Empty stack means that storage does not support parallel replicas.
|
||||
if (stack.empty())
|
||||
{
|
||||
LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Not found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// We don't have any subquery and storage can process parallel replicas by itself.
|
||||
if (stack.top() == query_tree_node.get())
|
||||
{
|
||||
LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Query itself:\n{}", query_tree_node->dumpTree());
|
||||
return query_node;
|
||||
}
|
||||
|
||||
/// This is needed to avoid infinite recursion.
|
||||
auto mutable_context = Context::createCopy(context);
|
||||
@ -303,7 +309,10 @@ const QueryNode * findQueryForParallelReplicas(const QueryTreeNodePtr & query_tr
|
||||
new_stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (!res)
|
||||
LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Not found 2");
|
||||
else
|
||||
LOG_DEBUG(getLogger(__PRETTY_FUNCTION__), "Query:\n{}", query_tree_node->dumpTree());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -88,34 +88,6 @@ right subs
|
||||
4 l5 \N 4 r6 nr6
|
||||
4 l6 \N 4 r6 nr6
|
||||
9 l9 \N 9 r9 nr9
|
||||
full
|
||||
0 \N 6 r7 nr7
|
||||
0 \N 7 r8 nr8
|
||||
1 l1 1 1 r1 \N
|
||||
1 l1 1 1 r2 \N
|
||||
2 l2 2 2 r3 \N
|
||||
2 l3 3 2 r3 \N
|
||||
3 l4 4 3 r4 \N
|
||||
3 l4 4 3 r5 \N
|
||||
4 l5 \N 4 r6 nr6
|
||||
4 l6 \N 4 r6 nr6
|
||||
5 l7 \N 0 \N
|
||||
8 l8 \N 0 \N
|
||||
9 l9 \N 9 r9 nr9
|
||||
full subs
|
||||
0 \N 6 r7 nr7
|
||||
0 \N 7 r8 nr8
|
||||
1 l1 1 1 r1 \N
|
||||
1 l1 1 1 r2 \N
|
||||
2 l2 2 2 r3 \N
|
||||
2 l3 3 2 r3 \N
|
||||
3 l4 4 3 r4 \N
|
||||
3 l4 4 3 r5 \N
|
||||
4 l5 \N 4 r6 nr6
|
||||
4 l6 \N 4 r6 nr6
|
||||
5 l7 \N 0 \N
|
||||
8 l8 \N 0 \N
|
||||
9 l9 \N 9 r9 nr9
|
||||
self inner
|
||||
1 l1 1 1 l1 1
|
||||
2 l2 2 2 l2 2
|
||||
@ -227,47 +199,3 @@ self right nullable vs not nullable
|
||||
3 l4 4 2 l3 3
|
||||
4 l5 \N 3 l4 4
|
||||
4 l6 \N 3 l4 4
|
||||
self full
|
||||
1 l1 1 1 l1 1
|
||||
2 l2 2 2 l2 2
|
||||
2 l2 2 2 l3 3
|
||||
2 l3 3 2 l2 2
|
||||
2 l3 3 2 l3 3
|
||||
3 l4 4 3 l4 4
|
||||
4 l5 \N 4 l5 \N
|
||||
4 l5 \N 4 l6 \N
|
||||
4 l6 \N 4 l5 \N
|
||||
4 l6 \N 4 l6 \N
|
||||
5 l7 \N 5 l7 \N
|
||||
8 l8 \N 8 l8 \N
|
||||
9 l9 \N 9 l9 \N
|
||||
self full nullable
|
||||
0 \N 4 l5 \N
|
||||
0 \N 4 l6 \N
|
||||
0 \N 5 l7 \N
|
||||
0 \N 8 l8 \N
|
||||
0 \N 9 l9 \N
|
||||
1 l1 1 1 l1 1
|
||||
2 l2 2 2 l2 2
|
||||
2 l3 3 2 l3 3
|
||||
3 l4 4 3 l4 4
|
||||
4 l5 \N 0 \N
|
||||
4 l6 \N 0 \N
|
||||
5 l7 \N 0 \N
|
||||
8 l8 \N 0 \N
|
||||
9 l9 \N 0 \N
|
||||
self full nullable vs not nullable
|
||||
0 \N 4 l5 \N
|
||||
0 \N 4 l6 \N
|
||||
0 \N 5 l7 \N
|
||||
0 \N 8 l8 \N
|
||||
0 \N 9 l9 \N
|
||||
1 l1 1 1 l1 1
|
||||
2 l2 2 2 l2 2
|
||||
2 l3 3 2 l2 2
|
||||
3 l4 4 2 l3 3
|
||||
4 l5 \N 3 l4 4
|
||||
4 l6 \N 3 l4 4
|
||||
5 l7 \N 0 \N
|
||||
8 l8 \N 0 \N
|
||||
9 l9 \N 0 \N
|
||||
|
@ -9,7 +9,7 @@ insert into X (id, x_a) values (4, 'l5'), (4, 'l6'), (5, 'l7'), (8, 'l8'),
|
||||
insert into Y (id, y_a) values (1, 'r1'), (1, 'r2'), (2, 'r3'), (3, 'r4'), (3, 'r5');
|
||||
insert into Y (id, y_a, y_b) values (4, 'r6', 'nr6'), (6, 'r7', 'nr7'), (7, 'r8', 'nr8'), (9, 'r9', 'nr9');
|
||||
|
||||
set enable_parallel_replicas = 2, max_parallel_replicas = 3, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', parallel_replicas_local_plan=1;
|
||||
set enable_parallel_replicas = 1, max_parallel_replicas = 3, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', parallel_replicas_local_plan=1;
|
||||
|
||||
select 'inner';
|
||||
select X.*, Y.* from X inner join Y on X.id = Y.id order by X.id, X.x_a, X.x_b, Y.id, Y.y_a, Y.y_b;
|
||||
@ -29,15 +29,6 @@ select 'right';
|
||||
select X.*, Y.* from X right join Y on X.id = Y.id order by X.id, X.x_a, X.x_b, Y.id, Y.y_a, Y.y_b;
|
||||
select 'right subs';
|
||||
select s.*, j.* from (select * from X) as s right join (select * from Y) as j on s.id = j.id order by s.id, s.x_a, s.x_b, j.id, j.y_a, j.y_b;
|
||||
--select 'right expr';
|
||||
--select X.*, Y.* from X right join Y on (X.id + 1) = (Y.id + 1) order by id;
|
||||
|
||||
select 'full';
|
||||
select X.*, Y.* from X full join Y on X.id = Y.id order by X.id, X.x_a, X.x_b, Y.id, Y.y_a, Y.y_b;
|
||||
select 'full subs';
|
||||
select s.*, j.* from (select * from X) as s full join (select * from Y) as j on s.id = j.id order by s.id, s.x_a, s.x_b, j.id, j.y_a, j.y_b;
|
||||
--select 'full expr';
|
||||
--select X.*, Y.* from X full join Y on (X.id + 1) = (Y.id + 1) order by id;
|
||||
|
||||
select 'self inner';
|
||||
select X.*, s.* from X inner join (select * from X) as s on X.id = s.id order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
@ -45,7 +36,6 @@ select 'self inner nullable';
|
||||
select X.*, s.* from X inner join (select * from X) as s on X.x_b = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
select 'self inner nullable vs not nullable';
|
||||
select X.*, s.* from X inner join (select * from X) as s on X.id = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
-- TODO: s.y_b == '' instead of NULL
|
||||
select 'self inner nullable vs not nullable 2';
|
||||
select Y.*, s.* from Y inner join (select * from Y) as s on concat('n', Y.y_a) = s.y_b order by Y.id, Y.y_a, Y.y_b, s.id, s.y_a, s.y_b;
|
||||
|
||||
@ -55,7 +45,6 @@ select 'self left nullable';
|
||||
select X.*, s.* from X left join (select * from X) as s on X.x_b = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
select 'self left nullable vs not nullable';
|
||||
select X.*, s.* from X left join (select * from X) as s on X.id = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
-- TODO: s.y_b == '' instead of NULL
|
||||
select 'self left nullable vs not nullable 2';
|
||||
select Y.*, s.* from Y left join (select * from Y) as s on concat('n', Y.y_a) = s.y_b order by Y.id, Y.y_a, Y.y_b, s.id, s.y_a, s.y_b;
|
||||
|
||||
@ -65,17 +54,6 @@ select 'self right nullable';
|
||||
select X.*, s.* from X right join (select * from X) as s on X.x_b = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
select 'self right nullable vs not nullable';
|
||||
select X.*, s.* from X right join (select * from X) as s on X.id = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
--select 'self right nullable vs not nullable 2';
|
||||
--select Y.*, s.* from Y right join (select * from Y) as s on concat('n', Y.y_a) = s.y_b order by id;
|
||||
|
||||
select 'self full';
|
||||
select X.*, s.* from X full join (select * from X) as s on X.id = s.id order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
select 'self full nullable';
|
||||
select X.*, s.* from X full join (select * from X) as s on X.x_b = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
select 'self full nullable vs not nullable';
|
||||
select X.*, s.* from X full join (select * from X) as s on X.id = s.x_b order by X.id, X.x_a, X.x_b, s.id, s.x_a, s.x_b;
|
||||
--select 'self full nullable vs not nullable 2';
|
||||
--select Y.*, s.* from Y full join (select * from Y) as s on concat('n', Y.y_a) = s.y_b order by id;
|
||||
|
||||
-- drop table X;
|
||||
-- drop table Y;
|
||||
drop table X sync;
|
||||
drop table Y sync;
|
||||
|
Loading…
Reference in New Issue
Block a user