diff --git a/src/backend/distributed/planner/query_pushdown_planning.c b/src/backend/distributed/planner/query_pushdown_planning.c index be3116fca..04c76275a 100644 --- a/src/backend/distributed/planner/query_pushdown_planning.c +++ b/src/backend/distributed/planner/query_pushdown_planning.c @@ -861,8 +861,9 @@ DeferredErrorIfUnsupportedRecurringTuplesJoin( { return DeferredError(ERRCODE_FEATURE_NOT_SUPPORTED, "cannot pushdown the subquery", - "Complex subqueries and CTEs cannot be in the outer " - "part of the outer join", NULL); + "Complex subqueries, CTEs and local tables cannot be in " + "the outer part of an outer join with a distributed table", + NULL); } return NULL; diff --git a/src/test/regress/expected/local_dist_join_mixed.out b/src/test/regress/expected/local_dist_join_mixed.out index b10cd112c..2baf2064d 100644 --- a/src/test/regress/expected/local_dist_join_mixed.out +++ b/src/test/regress/expected/local_dist_join_mixed.out @@ -1214,7 +1214,7 @@ DEBUG: Wrapping relation "local" to a subquery DEBUG: generating subplan XXX_1 for subquery SELECT id FROM local_dist_join_mixed.local WHERE true DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT local.id, distributed.name FROM ((SELECT NULL::integer AS "dummy-1", local_1.id, NULL::integer AS "dummy-3", NULL::text AS title, NULL::integer AS "dummy-5" FROM (SELECT intermediate_result.id FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(id bigint)) local_1) local LEFT JOIN local_dist_join_mixed.distributed USING (id)) ORDER BY local.id LIMIT 1 ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table SELECT foo1.id FROM diff --git a/src/test/regress/expected/local_table_join.out b/src/test/regress/expected/local_table_join.out index 13421da9d..81490dcda 100644 --- a/src/test/regress/expected/local_table_join.out +++ b/src/test/regress/expected/local_table_join.out @@ -1561,7 +1561,7 @@ DEBUG: generating subplan XXX_1 for subquery SELECT NULL::integer AS "dummy-1" DEBUG: generating subplan XXX_2 for subquery SELECT 1 FROM (SELECT NULL::integer AS a FROM (SELECT intermediate_result."dummy-1" FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result("dummy-1" integer)) table1_1) table1, local_table_join.table2 DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT 1 AS res FROM (local_table_join.table2 RIGHT JOIN (SELECT intermediate_result."?column?" FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result("?column?" integer)) sub1("?column?") ON (false)) ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table ROLLBACK; BEGIN; SELECT create_reference_table('table1'); diff --git a/src/test/regress/expected/multi_insert_select_non_pushable_queries.out b/src/test/regress/expected/multi_insert_select_non_pushable_queries.out index 788aeb750..222157a87 100644 --- a/src/test/regress/expected/multi_insert_select_non_pushable_queries.out +++ b/src/test/regress/expected/multi_insert_select_non_pushable_queries.out @@ -152,7 +152,7 @@ DEBUG: generating subplan XXX_2 for subquery SELECT u.user_id, 'step=>2'::text DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT intermediate_result.user_id, intermediate_result.event, intermediate_result."time" FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, event text, "time" timestamp without time zone) UNION SELECT intermediate_result.user_id, intermediate_result.event, intermediate_result."time" FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, event text, "time" timestamp without time zone) DEBUG: generating subplan XXX_1 for subquery SELECT u.user_id, 'step=>1'::text AS event, e."time" FROM public.users_table u, public.events_table e WHERE ((u.user_id OPERATOR(pg_catalog.=) e.user_id) AND (u.user_id OPERATOR(pg_catalog.>=) 10) AND (u.user_id OPERATOR(pg_catalog.<=) 25) AND (e.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[100, 101, 102]))) UNION SELECT u.user_id, 'step=>2'::text AS event, e."time" FROM public.users_table u, public.events_table e WHERE ((u.user_id OPERATOR(pg_catalog.=) e.user_id) AND (u.user_id OPERATOR(pg_catalog.>=) 10) AND (u.user_id OPERATOR(pg_catalog.<=) 25) AND (e.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[103, 104, 105]))) ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table RESET client_min_messages; --------------------------------------------------------------------- --------------------------------------------------------------------- @@ -302,7 +302,7 @@ DEBUG: generating subplan XXX_2 for subquery SELECT users_table.user_id, 'actio DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT intermediate_result.user_id, intermediate_result.event, intermediate_result."time" FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, event text, "time" timestamp without time zone) UNION SELECT intermediate_result.user_id, intermediate_result.event, intermediate_result."time" FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, event text, "time" timestamp without time zone) DEBUG: generating subplan XXX_1 for subquery SELECT users_table.user_id, 'action=>1'::text AS event, events_table."time" FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (users_table.user_id OPERATOR(pg_catalog.>=) 10) AND (users_table.user_id OPERATOR(pg_catalog.<=) 70) AND (events_table.event_type OPERATOR(pg_catalog.>) 10) AND (events_table.event_type OPERATOR(pg_catalog.<) 12)) UNION SELECT users_table.user_id, 'action=>2'::text AS event, events_table."time" FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (users_table.user_id OPERATOR(pg_catalog.>=) 10) AND (users_table.user_id OPERATOR(pg_catalog.<=) 70) AND (events_table.event_type OPERATOR(pg_catalog.>) 12) AND (events_table.event_type OPERATOR(pg_catalog.<) 14)) ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table RESET client_min_messages; --------------------------------------------------------------------- --------------------------------------------------------------------- diff --git a/src/test/regress/expected/multi_subquery_complex_reference_clause.out b/src/test/regress/expected/multi_subquery_complex_reference_clause.out index 9329e2df4..b9579ae7a 100644 --- a/src/test/regress/expected/multi_subquery_complex_reference_clause.out +++ b/src/test/regress/expected/multi_subquery_complex_reference_clause.out @@ -1530,7 +1530,7 @@ count(*) AS cnt, "generated_group_field" DEBUG: generating subplan XXX_1 for subquery SELECT user_id, value_2 AS generated_group_field FROM public.users_table users DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS cnt, generated_group_field FROM (SELECT "eventQuery".user_id, random() AS random, "eventQuery".generated_group_field FROM (SELECT multi_group_wrapper_1."time", multi_group_wrapper_1.event_user_id, multi_group_wrapper_1.user_id, left_group_by_1.generated_group_field, random() AS random FROM ((SELECT temp_data_queries."time", temp_data_queries.event_user_id, user_filters_1.user_id FROM ((SELECT events."time", events.user_id AS event_user_id FROM public.events_table events WHERE (events.user_id OPERATOR(pg_catalog.>) 2)) temp_data_queries JOIN (SELECT users.user_id FROM public.users_reference_table users WHERE ((users.user_id OPERATOR(pg_catalog.>) 2) AND (users.value_2 OPERATOR(pg_catalog.=) 5))) user_filters_1 ON ((temp_data_queries.event_user_id OPERATOR(pg_catalog.<) user_filters_1.user_id)))) multi_group_wrapper_1 RIGHT JOIN (SELECT intermediate_result.user_id, intermediate_result.generated_group_field FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, generated_group_field integer)) left_group_by_1 ON ((left_group_by_1.user_id OPERATOR(pg_catalog.>) multi_group_wrapper_1.event_user_id)))) "eventQuery") "pushedDownQuery" GROUP BY generated_group_field ORDER BY (count(*)) DESC, generated_group_field LIMIT 10 ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table RESET client_min_messages; -- two hash partitioned relations are not joined -- on partiton keys although reference table is fine @@ -2027,7 +2027,7 @@ DETAIL: There exist a reference table in the outer part of the outer join -- Postgres generates a LEFT JOIN alternative among those tables SELECT count(*) FROM (SELECT ref1.*, random() FROM users_ref_test_table ref1 INNER JOIN user_buy_test_table u1 on ref1.id = u1.user_id) as foo LEFT JOIN user_buy_test_table ON (foo.id = user_buy_test_table.user_id); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- same as the above query, but this time LEFT JOIN condition is between distributed tables -- so Postgres doesn't generate join restriction between reference and distributed tables SELECT count(*) FROM (SELECT u1.*, random() FROM users_ref_test_table ref1 INNER JOIN user_buy_test_table u1 on ref1.id = u1.user_id) as foo LEFT JOIN user_buy_test_table ON (foo.user_id = user_buy_test_table.user_id); @@ -2039,7 +2039,7 @@ SELECT count(*) FROM (SELECT u1.*, random() FROM users_ref_test_table ref1 INNER -- outer part of the LEFT JOIN consists only intermediate result due to LIMIT, so we cannot push down SELECT count(*) FROM (SELECT ref1.* FROM users_ref_test_table ref1 INNER JOIN users_ref_test_table ref2 on ref1.id = ref2.id LIMIT 5) as foo LEFT JOIN user_buy_test_table ON true; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- should be fine as OUTER part is the distributed table SELECT count(*) FROM users_ref_test_table ref1 INNER JOIN users_ref_test_table ref2 on ref1.id = ref2.id RIGHT JOIN user_buy_test_table ON true; count diff --git a/src/test/regress/expected/multi_subquery_in_where_clause.out b/src/test/regress/expected/multi_subquery_in_where_clause.out index c5066b275..b314f72d5 100644 --- a/src/test/regress/expected/multi_subquery_in_where_clause.out +++ b/src/test/regress/expected/multi_subquery_in_where_clause.out @@ -535,7 +535,7 @@ GROUP BY user_id HAVING count(*) > 1 AND sum(value_2) > 29 ORDER BY 1; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- NOT EXISTS query has non-equi join SELECT user_id, array_length(events_table, 1) FROM ( diff --git a/src/test/regress/expected/multi_view.out b/src/test/regress/expected/multi_view.out index 798108ce4..c7a6b44e0 100644 --- a/src/test/regress/expected/multi_view.out +++ b/src/test/regress/expected/multi_view.out @@ -496,7 +496,7 @@ SELECT * FROM ) s1 ORDER BY 2 DESC, 1; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- create a select only view CREATE VIEW selected_users AS SELECT * FROM users_table WHERE value_1 >= 1 and value_1 <3; CREATE VIEW recent_selected_users AS SELECT su.* FROM selected_users su JOIN recent_users ru USING(user_id); diff --git a/src/test/regress/expected/set_operation_and_local_tables.out b/src/test/regress/expected/set_operation_and_local_tables.out index fa38331e7..40c7d618c 100644 --- a/src/test/regress/expected/set_operation_and_local_tables.out +++ b/src/test/regress/expected/set_operation_and_local_tables.out @@ -253,7 +253,7 @@ DEBUG: generating subplan XXX_3 for subquery SELECT intermediate_result.x, inte DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT u.x, u.y, test.y FROM ((SELECT intermediate_result.x, intermediate_result.y FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(x integer, y integer)) u LEFT JOIN recursive_set_local.test USING (x)) ORDER BY u.x, u.y DEBUG: Router planner cannot handle multi-shard select queries ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- we replace some queries including the local query, the intermediate result is on the inner part of an outer join SELECT * FROM ((SELECT * FROM local_test) INTERSECT (SELECT * FROM test ORDER BY x LIMIT 1)) u RIGHT JOIN test USING (x) ORDER BY 1,2; DEBUG: Local tables cannot be used in distributed queries. diff --git a/src/test/regress/expected/set_operations.out b/src/test/regress/expected/set_operations.out index 47cf831bc..63abfe578 100644 --- a/src/test/regress/expected/set_operations.out +++ b/src/test/regress/expected/set_operations.out @@ -508,7 +508,7 @@ DEBUG: generating subplan XXX_3 for subquery SELECT intermediate_result.x, inte DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT u.x, u.y, test.y FROM ((SELECT intermediate_result.x, intermediate_result.y FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(x integer, y integer)) u LEFT JOIN recursive_union.test USING (x)) ORDER BY u.x, u.y DEBUG: Router planner cannot handle multi-shard select queries ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- unions in a join without partition column equality (column names from first query are used for join) SELECT * FROM ((SELECT x, y FROM test) UNION (SELECT y, x FROM test)) u JOIN test USING (x) ORDER BY 1,2; DEBUG: Router planner cannot handle multi-shard select queries @@ -689,7 +689,7 @@ DEBUG: generating subplan XXX_3 for subquery SELECT intermediate_result.x, inte DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT u.x, u.y, test.y FROM ((SELECT intermediate_result.x, intermediate_result.y FROM read_intermediate_result('XXX_3'::text, 'binary'::citus_copy_format) intermediate_result(x integer, y integer)) u LEFT JOIN recursive_union.test USING (x)) ORDER BY u.x, u.y DEBUG: Router planner cannot handle multi-shard select queries ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- distributed table in WHERE clause is recursively planned SELECT * FROM ((SELECT * FROM test) UNION (SELECT * FROM ref WHERE a IN (SELECT x FROM test))) u ORDER BY 1,2; DEBUG: Router planner cannot handle multi-shard select queries diff --git a/src/test/regress/expected/sqlancer_failures.out b/src/test/regress/expected/sqlancer_failures.out index 771897777..47a83665f 100644 --- a/src/test/regress/expected/sqlancer_failures.out +++ b/src/test/regress/expected/sqlancer_failures.out @@ -181,7 +181,7 @@ SELECT count(*) FROM distributed_table a LEFT JOIN (SELECT * FROM reference_table OFFSET 0) b ON (true) RIGHT JOIN (SELECT * FROM reference_table OFFSET 0) c ON (true); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table SELECT count(*) FROM distributed_table a LEFT JOIN reference_table b ON (true) RIGHT JOIN reference_table c ON (c.id > 0); @@ -191,7 +191,7 @@ SELECT count(*) FROM distributed_table a LEFT JOIN (SELECT * FROM reference_table OFFSET 0) b ON (true) RIGHT JOIN (SELECT * FROM reference_table OFFSET 0) c ON (c.id > 0); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- drop existing sqlancer tables before next tests DROP TABLE t0, t1, t2, t3, t4 CASCADE; CREATE TABLE IF NOT EXISTS t0(c0 TEXT CHECK (TRUE), c1 money ) WITH (autovacuum_vacuum_threshold=1180014707, autovacuum_freeze_table_age=13771154, autovacuum_vacuum_cost_delay=23, autovacuum_analyze_threshold=1935153914, autovacuum_freeze_min_age=721733768, autovacuum_enabled=0, autovacuum_vacuum_cost_limit=9983); @@ -303,7 +303,7 @@ JOIN ) AS unsupported_join ON (true); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- unsupported outer JOIN in a sublevel INNER JOIN SELECT unsupported_join.* @@ -341,7 +341,7 @@ LEFT JOIN ) ON (true); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- unsupported outer JOIN in a sublevel RIGHT JOIN SELECT unsupported_join.* @@ -368,7 +368,7 @@ RIGHT JOIN ) ON (true); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table EXPLAIN SELECT unsupported_join.* FROM diff --git a/src/test/regress/expected/subqueries_not_supported.out b/src/test/regress/expected/subqueries_not_supported.out index fcd33386e..b69256866 100644 --- a/src/test/regress/expected/subqueries_not_supported.out +++ b/src/test/regress/expected/subqueries_not_supported.out @@ -82,7 +82,7 @@ DEBUG: push down of limit count: 5 DEBUG: generating subplan XXX_1 for subquery SELECT users_table.value_2 FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4]))) LIMIT 5 DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT foo.value_2 FROM ((SELECT intermediate_result.value_2 FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(value_2 integer)) foo LEFT JOIN (SELECT users_table.value_2 FROM public.users_table, public.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[5, 6, 7, 8])))) bar ON ((foo.value_2 OPERATOR(pg_catalog.=) bar.value_2))) ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- We do not support GROUPING SETS in subqueries -- This also includes ROLLUP or CUBE clauses SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY GROUPING SETS ((user_id), (value_1))) s; diff --git a/src/test/regress/expected/with_basics.out b/src/test/regress/expected/with_basics.out index 819b25fc5..0d0070fd6 100644 --- a/src/test/regress/expected/with_basics.out +++ b/src/test/regress/expected/with_basics.out @@ -841,7 +841,7 @@ LEFT JOIN ON distinct_undistribured.user_id = exsist_in_distributed.user_id ORDER BY 2 DESC, 1 DESC; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- similar query as the above, but this time -- use NOT EXITS, which is pretty common struct WITH distinct_undistribured AS @@ -857,7 +857,7 @@ LEFT JOIN FROM distinct_undistribured WHERE distinct_undistribured.user_id = test_cte_distributed.user_id)) exsist_in_distributed ON distinct_undistribured.user_id = exsist_in_distributed.user_id; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- same NOT EXISTS struct, but with CTE -- so should work WITH distinct_undistribured AS ( @@ -906,7 +906,7 @@ LEFT JOIN FROM distinct_undistribured d2 WHERE d1.user_id = d2.user_id )) AS bar USING (user_id); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- should work fine with materialized ctes WITH distinct_undistribured AS MATERIALIZED ( SELECT DISTINCT user_id @@ -952,7 +952,7 @@ LEFT JOIN ON distinct_undistribured.user_id = exsist_in_distributed.user_id ORDER BY 2 DESC, 1 DESC; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table WITH distinct_undistribured AS MATERIALIZED (SELECT DISTINCT user_id FROM test_cte) @@ -966,7 +966,7 @@ LEFT JOIN FROM distinct_undistribured WHERE distinct_undistribured.user_id = test_cte_distributed.user_id)) exsist_in_distributed ON distinct_undistribured.user_id = exsist_in_distributed.user_id; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- NOT EXISTS struct, with cte inlining disabled WITH distinct_undistribured AS MATERIALIZED( SELECT DISTINCT user_id @@ -1014,7 +1014,7 @@ LEFT JOIN FROM distinct_undistribured d2 WHERE d1.user_id = d2.user_id )) AS bar USING (user_id); ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- some test with failures WITH a AS MATERIALIZED (SELECT * FROM users_table LIMIT 10) SELECT user_id/0 FROM users_table JOIN a USING (user_id); diff --git a/src/test/regress/expected/with_join.out b/src/test/regress/expected/with_join.out index 28166b31c..f20334403 100644 --- a/src/test/regress/expected/with_join.out +++ b/src/test/regress/expected/with_join.out @@ -167,7 +167,7 @@ ORDER BY LIMIT 5; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- cte RIGHT JOIN distributed_table should work WITH cte AS MATERIALIZED ( SELECT * FROM users_table WHERE user_id = 1 ORDER BY value_1 @@ -229,7 +229,7 @@ ORDER BY LIMIT 5; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- cte FULL JOIN distributed_table should error out WITH cte AS MATERIALIZED ( SELECT * FROM users_table WHERE user_id = 1 ORDER BY value_1 @@ -245,7 +245,7 @@ ORDER BY LIMIT 5; ERROR: cannot pushdown the subquery -DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join +DETAIL: Complex subqueries, CTEs and local tables cannot be in the outer part of an outer join with a distributed table -- Joins with reference tables are planned as router queries WITH cte AS MATERIALIZED ( SELECT value_2, max(user_id) AS user_id FROM users_table WHERE value_2 = 1 GROUP BY value_2 HAVING count(*) > 1