Merge pull request #2683 from citusdata/order_by_fix_5

Add ORDER BYs to multi_subquery and subqueries_deep tests
pull/2664/head
Önder Kalacı 2019-04-25 10:52:10 +02:00 committed by GitHub
commit 116c255d3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 11 deletions

View File

@ -134,7 +134,7 @@ FROM
FROM FROM
lineitem_subquery lineitem_subquery
ORDER BY ORDER BY
l_quantity l_orderkey, l_quantity
LIMIT 10 LIMIT 10
) lineitem_quantities ) lineitem_quantities
JOIN LATERAL JOIN LATERAL
@ -145,8 +145,8 @@ FROM
WHERE WHERE
lineitem_quantities.l_orderkey = o_orderkey) orders_price ON true; lineitem_quantities.l_orderkey = o_orderkey) orders_price ON true;
avg avg
------------------------- ------------------------
129027.1270000000000000 17470.0940725222668915
(1 row) (1 row)
-- Limit is only supported when subquery_pushdown is set -- Limit is only supported when subquery_pushdown is set
@ -161,7 +161,7 @@ FROM
FROM FROM
lineitem_subquery lineitem_subquery
ORDER BY ORDER BY
l_quantity l_orderkey, l_quantity
LIMIT 10 LIMIT 10
) lineitem_quantities ) lineitem_quantities
JOIN LATERAL JOIN LATERAL

View File

@ -17,7 +17,7 @@ FROM
avg(event_type) as avg_val avg(event_type) as avg_val
FROM FROM
(SELECT event_type, users_table.user_id FROM users_table, (SELECT event_type, users_table.user_id FROM users_table,
(SELECT user_id, event_type FROM events_table WHERE value_2 < 3 OFFSET 3) as foo (SELECT user_id, event_type FROM events_table WHERE value_2 < 3 ORDER BY 1, 2 OFFSET 3) as foo
WHERE foo.user_id = users_table.user_id WHERE foo.user_id = users_table.user_id
) bar, users_table WHERE bar.user_id = users_table.user_id GROUP BY users_table.value_1 ) bar, users_table WHERE bar.user_id = users_table.user_id GROUP BY users_table.value_1
) as baz ) as baz
@ -25,7 +25,7 @@ FROM
LIMIT 3 LIMIT 3
) as sub1 ) as sub1
ORDER BY 1 DESC; ORDER BY 1 DESC;
DEBUG: generating subplan 1_1 for subquery SELECT user_id, event_type FROM public.events_table WHERE (value_2 OPERATOR(pg_catalog.<) 3) OFFSET 3 DEBUG: generating subplan 1_1 for subquery SELECT user_id, event_type FROM public.events_table WHERE (value_2 OPERATOR(pg_catalog.<) 3) ORDER BY user_id, event_type OFFSET 3
DEBUG: generating subplan 1_2 for subquery SELECT avg(bar.event_type) AS avg_val FROM (SELECT foo.event_type, users_table_1.user_id FROM public.users_table users_table_1, (SELECT intermediate_result.user_id, intermediate_result.event_type FROM read_intermediate_result('1_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, event_type integer)) foo WHERE (foo.user_id OPERATOR(pg_catalog.=) users_table_1.user_id)) bar, public.users_table WHERE (bar.user_id OPERATOR(pg_catalog.=) users_table.user_id) GROUP BY users_table.value_1 DEBUG: generating subplan 1_2 for subquery SELECT avg(bar.event_type) AS avg_val FROM (SELECT foo.event_type, users_table_1.user_id FROM public.users_table users_table_1, (SELECT intermediate_result.user_id, intermediate_result.event_type FROM read_intermediate_result('1_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer, event_type integer)) foo WHERE (foo.user_id OPERATOR(pg_catalog.=) users_table_1.user_id)) bar, public.users_table WHERE (bar.user_id OPERATOR(pg_catalog.=) users_table.user_id) GROUP BY users_table.value_1
DEBUG: push down of limit count: 3 DEBUG: push down of limit count: 3
DEBUG: generating subplan 1_3 for subquery SELECT users_table.user_id FROM public.users_table, (SELECT intermediate_result.avg_val FROM read_intermediate_result('1_2'::text, 'binary'::citus_copy_format) intermediate_result(avg_val numeric)) baz WHERE (baz.avg_val OPERATOR(pg_catalog.<) (users_table.user_id)::numeric) LIMIT 3 DEBUG: generating subplan 1_3 for subquery SELECT users_table.user_id FROM public.users_table, (SELECT intermediate_result.avg_val FROM read_intermediate_result('1_2'::text, 'binary'::citus_copy_format) intermediate_result(avg_val numeric)) baz WHERE (baz.avg_val OPERATOR(pg_catalog.<) (users_table.user_id)::numeric) LIMIT 3

View File

@ -100,7 +100,7 @@ FROM
FROM FROM
lineitem_subquery lineitem_subquery
ORDER BY ORDER BY
l_quantity l_orderkey, l_quantity
LIMIT 10 LIMIT 10
) lineitem_quantities ) lineitem_quantities
JOIN LATERAL JOIN LATERAL
@ -123,7 +123,7 @@ FROM
FROM FROM
lineitem_subquery lineitem_subquery
ORDER BY ORDER BY
l_quantity l_orderkey, l_quantity
LIMIT 10 LIMIT 10
) lineitem_quantities ) lineitem_quantities
JOIN LATERAL JOIN LATERAL

View File

@ -5,7 +5,6 @@ CREATE SCHEMA subquery_deep;
SET search_path TO subquery_and_ctes, public; SET search_path TO subquery_and_ctes, public;
SET client_min_messages TO DEBUG1; SET client_min_messages TO DEBUG1;
-- subquery in FROM -> FROM -> FROM should be replaced due to OFFSET -- subquery in FROM -> FROM -> FROM should be replaced due to OFFSET
-- one level up subquery should be replaced due to GROUP BY on non partition key -- one level up subquery should be replaced due to GROUP BY on non partition key
-- one level up subquery should be replaced due to LIMUT -- one level up subquery should be replaced due to LIMUT
@ -19,7 +18,7 @@ FROM
avg(event_type) as avg_val avg(event_type) as avg_val
FROM FROM
(SELECT event_type, users_table.user_id FROM users_table, (SELECT event_type, users_table.user_id FROM users_table,
(SELECT user_id, event_type FROM events_table WHERE value_2 < 3 OFFSET 3) as foo (SELECT user_id, event_type FROM events_table WHERE value_2 < 3 ORDER BY 1, 2 OFFSET 3) as foo
WHERE foo.user_id = users_table.user_id WHERE foo.user_id = users_table.user_id
) bar, users_table WHERE bar.user_id = users_table.user_id GROUP BY users_table.value_1 ) bar, users_table WHERE bar.user_id = users_table.user_id GROUP BY users_table.value_1