diff --git a/src/test/regress/expected/recurring_join_pushdown.out b/src/test/regress/expected/recurring_join_pushdown.out index 732dc4935..e9ba8da80 100644 --- a/src/test/regress/expected/recurring_join_pushdown.out +++ b/src/test/regress/expected/recurring_join_pushdown.out @@ -34,6 +34,14 @@ CREATE TABLE d1_local(like d1); INSERT INTO d1_local select * from d1; CREATE TABLE d2_local(like d2); INSERT INTO d2_local select * from d2; +SET citus.shard_count TO 2; +CREATE TABLE d3_not_colocated(like d1); +SELECT create_distributed_table('d3_not_colocated', 'a'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + SET client_min_messages TO DEBUG3; -- Basic test cases -- Test that the join is pushed down to the worker nodes, using "using" syntax @@ -116,6 +124,14 @@ SELECT count(*) FROM r1_local LEFT JOIN d1_local USING (b); 16 (1 row) +-- Test that the join is not pushed down when we have non-colocated tables in the RHS +SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated FULL JOIN d1 ON d3_not_colocated.a = d1.a) USING (a); +ERROR: cannot push down this subquery +DETAIL: d3_not_colocated and d1 are not colocated +-- The same error with its RIGHT JOIN variant +SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated JOIN d1 ON d3_not_colocated.a = d1.a) USING (a); +ERROR: cannot push down this subquery +DETAIL: d3_not_colocated and d1 are not colocated -- Basic test cases with ON syntax -- Test that the join is pushed down to the worker nodes, using "on" syntax SET client_min_messages TO DEBUG3; diff --git a/src/test/regress/sql/recurring_join_pushdown.sql b/src/test/regress/sql/recurring_join_pushdown.sql index 70feda4bf..6522839bf 100644 --- a/src/test/regress/sql/recurring_join_pushdown.sql +++ b/src/test/regress/sql/recurring_join_pushdown.sql @@ -27,6 +27,11 @@ INSERT INTO d1_local select * from d1; CREATE TABLE d2_local(like d2); INSERT INTO d2_local select * from d2; +SET citus.shard_count TO 2; +CREATE TABLE d3_not_colocated(like d1); +SELECT create_distributed_table('d3_not_colocated', 'a'); + + SET client_min_messages TO DEBUG3; -- Basic test cases @@ -42,6 +47,11 @@ SET client_min_messages TO DEBUG1; SELECT count(*) FROM r1 LEFT JOIN d1 USING (b); SELECT count(*) FROM r1_local LEFT JOIN d1_local USING (b); +-- Test that the join is not pushed down when we have non-colocated tables in the RHS +SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated FULL JOIN d1 ON d3_not_colocated.a = d1.a) USING (a); +-- The same error with its RIGHT JOIN variant +SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated JOIN d1 ON d3_not_colocated.a = d1.a) USING (a); + -- Basic test cases with ON syntax -- Test that the join is pushed down to the worker nodes, using "on" syntax SET client_min_messages TO DEBUG3;