-- =================================================================== -- test recursive planning functionality on failure cases -- =================================================================== CREATE SCHEMA not_supported; SET search_path TO not_supported, public; SET citus.coordinator_aggregation_strategy TO 'disabled'; SET client_min_messages TO DEBUG1; CREATE TABLE users_table_local AS SELECT * FROM users_table; RESET client_min_messages; -- we don't support subqueries with local tables when they are not leaf queries SELECT COUNT(user_id) FROM users_table WHERE user_id IN (SELECT user_id FROM users_table_local JOIN (SELECT user_id FROM events_table_local) as foo USING (user_id) ); ERROR: relation "events_table_local" does not exist SET client_min_messages TO DEBUG1; -- we don't support aggregate distinct if the group by is not on partition key, expect for count distinct -- thus baz and bar are recursively planned but not foo SELECT * FROM ( SELECT avg(DISTINCT value_1), random() FROM users_table GROUP BY user_id OFFSET 3 ) as baz, ( SELECT count(DISTINCT value_1), random() FROM users_table GROUP BY value_2 OFFSET 3 ) as bar, ( SELECT avg(DISTINCT value_1), random() FROM users_table GROUP BY value_2 OFFSET 3 ) as foo; DEBUG: generating subplan XXX_1 for subquery SELECT avg(DISTINCT value_1) AS avg, random() AS random FROM public.users_table GROUP BY user_id OFFSET 3 DEBUG: generating subplan XXX_2 for subquery SELECT count(DISTINCT value_1) AS count, random() AS random FROM public.users_table GROUP BY value_2 OFFSET 3 ERROR: cannot compute aggregate (distinct) DETAIL: table partitioning is unsuitable for aggregate (distinct) -- we don't support array_aggs with ORDER BYs SELECT * FROM ( SELECT array_agg(users_table.value_2 ORDER BY users_table.time) FROM users_table, (SELECT user_id FROM events_table) as evs WHERE users_table.user_id = evs.user_id GROUP BY users_table.value_2 LIMIT 5 ) as foo; ERROR: array_agg with order by is unsupported -- we don't support recursive subqueries when router executor is disabled SET citus.enable_router_execution TO false; SELECT user_id FROM (SELECT DISTINCT users_table.user_id FROM users_table, events_table WHERE users_table.user_id = events_table.user_id AND event_type IN (1,2,3,4) ORDER BY 1 DESC LIMIT 5 ) as foo ORDER BY 1 DESC; DEBUG: push down of limit count: 5 DEBUG: generating subplan XXX_1 for subquery SELECT DISTINCT users_table.user_id 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]))) ORDER BY users_table.user_id DESC LIMIT 5 DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT user_id FROM (SELECT intermediate_result.user_id FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer)) foo ORDER BY user_id DESC ERROR: cannot handle complex subqueries when the router executor is disabled SET citus.enable_router_execution TO true; -- OUTER JOINs where the outer part is recursively planned and not the other way -- around are supported SELECT foo.value_2 INTO result_table FROM (SELECT users_table.value_2 FROM users_table, events_table WHERE users_table.user_id = events_table.user_id AND event_type IN (1,2,3,4) ORDER BY users_table.value_2 LIMIT 5) as foo LEFT JOIN (SELECT users_table.value_2 FROM users_table, events_table WHERE users_table.user_id = events_table.user_id AND event_type IN (5,6,7,8)) as bar ON(foo.value_2 = bar.value_2); 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]))) ORDER BY users_table.value_2 LIMIT 5 DEBUG: recursively planning right side of the left join since the outer side is a recurring rel DEBUG: recursively planning the distributed subquery since it is part of a distributed join node that is outer joined with a recurring rel DEBUG: generating subplan XXX_2 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[5, 6, 7, 8]))) 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 intermediate_result.value_2 FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(value_2 integer)) bar ON ((foo.value_2 OPERATOR(pg_catalog.=) bar.value_2))) SELECT COUNT(*) = 60 FROM result_table WHERE value_2 = 0; ?column? --------------------------------------------------------------------- t (1 row) SELECT COUNT(*) = 0 FROM result_table WHERE value_2 != 0; ?column? --------------------------------------------------------------------- t (1 row) DROP TABLE result_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; ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP HINT: Consider using an equality filter on the distributed table's partition column. SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY ROLLUP (user_id, value_1)) s; ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP HINT: Consider using an equality filter on the distributed table's partition column. SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY CUBE (user_id, value_1)) s; ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP HINT: Consider using an equality filter on the distributed table's partition column. SET client_min_messages TO DEFAULT; DROP SCHEMA not_supported CASCADE; NOTICE: drop cascades to table users_table_local SET search_path TO public;