From db11324ac790b17fa43f943f6585598cef0a6f94 Mon Sep 17 00:00:00 2001 From: Jason Petersen Date: Fri, 21 Apr 2017 15:10:22 -0600 Subject: [PATCH] Add unambiguous ORDER BY clauses to many tests Queries which do not specify an order may arbitrarily change output across PostgreSQL versions. --- .../expected/multi_complex_expressions.out | 23 +++--- .../regress/expected/multi_insert_select.out | 24 +++--- .../expected/multi_mx_reference_table.out | 27 ++++--- .../expected/multi_mx_router_planner.out | 56 +++++-------- .../expected/multi_reference_table.out | 27 ++++--- .../regress/expected/multi_router_planner.out | 81 +++++++++---------- src/test/regress/input/multi_subquery.source | 4 +- src/test/regress/output/multi_subquery.source | 6 +- .../regress/output/multi_subquery_0.source | 6 +- .../regress/sql/multi_complex_expressions.sql | 3 +- src/test/regress/sql/multi_insert_select.sql | 6 +- .../regress/sql/multi_mx_reference_table.sql | 27 ++++--- .../regress/sql/multi_mx_router_planner.sql | 25 +++--- .../regress/sql/multi_reference_table.sql | 27 ++++--- src/test/regress/sql/multi_router_planner.sql | 47 ++++++----- 15 files changed, 214 insertions(+), 175 deletions(-) diff --git a/src/test/regress/expected/multi_complex_expressions.out b/src/test/regress/expected/multi_complex_expressions.out index 0914adb6f..1c72e5afe 100644 --- a/src/test/regress/expected/multi_complex_expressions.out +++ b/src/test/regress/expected/multi_complex_expressions.out @@ -435,22 +435,21 @@ FROM lineitem li JOIN orders o ON li.l_orderkey = o.o_orderkey WHERE li.l_quantity > 25 -ORDER BY - li.l_quantity, li.l_partkey, o.o_custkey +ORDER BY 1, 2, 3 LIMIT 10 OFFSET 20; DEBUG: push down of limit count: 30 l_partkey | o_custkey | l_quantity -----------+-----------+------------ - 25221 | 656 | 26.00 - 25373 | 1369 | 26.00 - 27331 | 571 | 26.00 - 27699 | 1150 | 26.00 - 28226 | 913 | 26.00 - 28635 | 1207 | 26.00 - 29101 | 1283 | 26.00 - 31143 | 640 | 26.00 - 31239 | 685 | 26.00 - 33646 | 860 | 26.00 + 655 | 58 | 50.00 + 669 | 319 | 34.00 + 699 | 1255 | 50.00 + 716 | 61 | 45.00 + 723 | 14 | 36.00 + 802 | 754 | 50.00 + 831 | 589 | 32.00 + 835 | 67 | 33.00 + 864 | 439 | 32.00 + 875 | 13 | 43.00 (10 rows) RESET client_min_messages; diff --git a/src/test/regress/expected/multi_insert_select.out b/src/test/regress/expected/multi_insert_select.out index ada4fc4d9..72962f0a7 100644 --- a/src/test/regress/expected/multi_insert_select.out +++ b/src/test/regress/expected/multi_insert_select.out @@ -292,14 +292,15 @@ FROM (SELECT raw_events_second.user_id AS id, FROM raw_events_first, raw_events_second WHERE raw_events_first.user_id = raw_events_second.user_id) AS foo -GROUP BY id; -DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= '-2147483648'::integer) AND (worker_hash(id) <= '-1073741825'::integer)) GROUP BY id -DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300001 raw_events_first, public.raw_events_second_13300005 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= '-1073741824'::integer) AND (worker_hash(id) <= '-1'::integer)) GROUP BY id -DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300002 raw_events_first, public.raw_events_second_13300006 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= 0) AND (worker_hash(id) <= 1073741823)) GROUP BY id -DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= 1073741824) AND (worker_hash(id) <= 2147483647)) GROUP BY id +GROUP BY id +ORDER BY id; +DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= '-2147483648'::integer) AND (worker_hash(id) <= '-1073741825'::integer)) GROUP BY id ORDER BY id +DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300001 raw_events_first, public.raw_events_second_13300005 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= '-1073741824'::integer) AND (worker_hash(id) <= '-1'::integer)) GROUP BY id ORDER BY id +DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300002 raw_events_first, public.raw_events_second_13300006 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= 0) AND (worker_hash(id) <= 1073741823)) GROUP BY id ORDER BY id +DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo WHERE ((worker_hash(id) >= 1073741824) AND (worker_hash(id) <= 2147483647)) GROUP BY id ORDER BY id DEBUG: Plan is router executable ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008" -DETAIL: Key (user_id, value_1_agg)=(5, 50) already exists. +DETAIL: Key (user_id, value_1_agg)=(1, 10) already exists. CONTEXT: while executing command on localhost:57638 -- subquery one more level depth INSERT INTO agg_events @@ -315,11 +316,12 @@ FROM (SELECT SUM(raw_events_second.value_4) AS v4, FROM raw_events_first, raw_events_second WHERE raw_events_first.user_id = raw_events_second.user_id - GROUP BY raw_events_second.user_id) AS foo; -DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= '-2147483648'::integer) AND (worker_hash(id) <= '-1073741825'::integer)) -DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300001 raw_events_first, public.raw_events_second_13300005 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= '-1073741824'::integer) AND (worker_hash(id) <= '-1'::integer)) -DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300002 raw_events_first, public.raw_events_second_13300006 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= 0) AND (worker_hash(id) <= 1073741823)) -DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= 1073741824) AND (worker_hash(id) <= 2147483647)) + GROUP BY raw_events_second.user_id) AS foo +ORDER BY id; +DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= '-2147483648'::integer) AND (worker_hash(id) <= '-1073741825'::integer)) ORDER BY id +DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300001 raw_events_first, public.raw_events_second_13300005 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= '-1073741824'::integer) AND (worker_hash(id) <= '-1'::integer)) ORDER BY id +DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300002 raw_events_first, public.raw_events_second_13300006 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= 0) AND (worker_hash(id) <= 1073741823)) ORDER BY id +DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) >= 1073741824) AND (worker_hash(id) <= 2147483647)) ORDER BY id DEBUG: Plan is router executable ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008" DETAIL: Key (user_id, value_1_agg)=(1, 10) already exists. diff --git a/src/test/regress/expected/multi_mx_reference_table.out b/src/test/regress/expected/multi_mx_reference_table.out index d49c0cb06..3e788d2e6 100644 --- a/src/test/regress/expected/multi_mx_reference_table.out +++ b/src/test/regress/expected/multi_mx_reference_table.out @@ -312,26 +312,35 @@ WHERE (2 rows) -- set operations are supported -(SELECT * FROM reference_table_test WHERE value_1 = 1) -UNION -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + UNION + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; value_1 | value_2 | value_3 | value_4 ---------+---------+---------+-------------------------- 1 | 1 | 1 | Thu Dec 01 00:00:00 2016 3 | 3 | 3 | Sat Dec 03 00:00:00 2016 (2 rows) -(SELECT * FROM reference_table_test WHERE value_1 = 1) -EXCEPT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + EXCEPT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; value_1 | value_2 | value_3 | value_4 ---------+---------+---------+-------------------------- 1 | 1 | 1 | Thu Dec 01 00:00:00 2016 (1 row) -(SELECT * FROM reference_table_test WHERE value_1 = 1) -INTERSECT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + INTERSECT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; value_1 | value_2 | value_3 | value_4 ---------+---------+---------+--------- (0 rows) diff --git a/src/test/regress/expected/multi_mx_router_planner.out b/src/test/regress/expected/multi_mx_router_planner.out index da1fa9646..bb03d3905 100644 --- a/src/test/regress/expected/multi_mx_router_planner.out +++ b/src/test/regress/expected/multi_mx_router_planner.out @@ -355,7 +355,8 @@ SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash_mx WHERE author_id = 1 or author_id = 3 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; DEBUG: Creating router plan DEBUG: Plan is router executable id | subtitle | count @@ -385,7 +386,8 @@ SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash_mx WHERE author_id = 1 or author_id = 2 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; 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. -- queries which involve functions in FROM clause are supported if it goes to a single worker. @@ -708,43 +710,26 @@ DEBUG: Plan is router executable -- router plannable union queries are supported -(SELECT * FROM articles_hash_mx WHERE author_id = 1) -UNION -(SELECT * FROM articles_hash_mx WHERE author_id = 3); -DEBUG: Creating router plan -DEBUG: Plan is router executable - id | author_id | title | word_count -----+-----------+--------------+------------ - 3 | 3 | asternal | 10480 - 43 | 3 | affixal | 12723 - 23 | 3 | abhorring | 6799 - 13 | 3 | aseyev | 2255 - 11 | 1 | alamo | 1347 - 41 | 1 | aznavour | 11814 - 1 | 1 | arsenous | 9572 - 21 | 1 | arcading | 5890 - 31 | 1 | athwartships | 7271 - 33 | 3 | autochrome | 8180 -(10 rows) - SELECT * FROM ( - (SELECT * FROM articles_hash_mx WHERE author_id = 1) + SELECT * FROM articles_hash_mx WHERE author_id = 1 UNION - (SELECT * FROM articles_hash_mx WHERE author_id = 3)) uu; + SELECT * FROM articles_hash_mx WHERE author_id = 3 +) AS combination +ORDER BY id; DEBUG: Creating router plan DEBUG: Plan is router executable id | author_id | title | word_count ----+-----------+--------------+------------ - 3 | 3 | asternal | 10480 - 43 | 3 | affixal | 12723 - 23 | 3 | abhorring | 6799 - 13 | 3 | aseyev | 2255 - 11 | 1 | alamo | 1347 - 41 | 1 | aznavour | 11814 1 | 1 | arsenous | 9572 + 3 | 3 | asternal | 10480 + 11 | 1 | alamo | 1347 + 13 | 3 | aseyev | 2255 21 | 1 | arcading | 5890 + 23 | 3 | abhorring | 6799 31 | 1 | athwartships | 7271 33 | 3 | autochrome | 8180 + 41 | 1 | aznavour | 11814 + 43 | 3 | affixal | 12723 (10 rows) (SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 1) @@ -767,17 +752,20 @@ DEBUG: Plan is router executable a (1 row) -(SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 1) -EXCEPT -(SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 3); +SELECT * FROM ( + SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 1 + EXCEPT + SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 3 +) AS combination +ORDER BY 1; DEBUG: Creating router plan DEBUG: Plan is router executable left ------ + al + ar at az - ar - al (4 rows) -- union queries are not supported if not router plannable diff --git a/src/test/regress/expected/multi_reference_table.out b/src/test/regress/expected/multi_reference_table.out index 59700a0cd..dc1b94891 100644 --- a/src/test/regress/expected/multi_reference_table.out +++ b/src/test/regress/expected/multi_reference_table.out @@ -360,26 +360,35 @@ WHERE (2 rows) -- set operations are supported -(SELECT * FROM reference_table_test WHERE value_1 = 1) -UNION -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + UNION + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; value_1 | value_2 | value_3 | value_4 ---------+---------+---------+-------------------------- 1 | 1 | 1 | Thu Dec 01 00:00:00 2016 3 | 3 | 3 | Sat Dec 03 00:00:00 2016 (2 rows) -(SELECT * FROM reference_table_test WHERE value_1 = 1) -EXCEPT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + EXCEPT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; value_1 | value_2 | value_3 | value_4 ---------+---------+---------+-------------------------- 1 | 1 | 1 | Thu Dec 01 00:00:00 2016 (1 row) -(SELECT * FROM reference_table_test WHERE value_1 = 1) -INTERSECT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + INTERSECT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; value_1 | value_2 | value_3 | value_4 ---------+---------+---------+--------- (0 rows) diff --git a/src/test/regress/expected/multi_router_planner.out b/src/test/regress/expected/multi_router_planner.out index 369ee2f32..c6ac05c4d 100644 --- a/src/test/regress/expected/multi_router_planner.out +++ b/src/test/regress/expected/multi_router_planner.out @@ -453,7 +453,8 @@ SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash WHERE author_id = 1 or author_id = 3 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; DEBUG: Creating router plan DEBUG: Plan is router executable id | subtitle | count @@ -483,7 +484,8 @@ SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash WHERE author_id = 1 or author_id = 2 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; 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. -- queries which involve functions in FROM clause are supported if it goes to a single worker. @@ -820,45 +822,27 @@ DEBUG: Plan is router executable 11814 (1 row) - -- router plannable union queries are supported -(SELECT * FROM articles_hash WHERE author_id = 1) -UNION -(SELECT * FROM articles_hash WHERE author_id = 3); -DEBUG: Creating router plan -DEBUG: Plan is router executable - id | author_id | title | word_count -----+-----------+--------------+------------ - 3 | 3 | asternal | 10480 - 43 | 3 | affixal | 12723 - 23 | 3 | abhorring | 6799 - 13 | 3 | aseyev | 2255 - 11 | 1 | alamo | 1347 - 41 | 1 | aznavour | 11814 - 1 | 1 | arsenous | 9572 - 21 | 1 | arcading | 5890 - 31 | 1 | athwartships | 7271 - 33 | 3 | autochrome | 8180 -(10 rows) - SELECT * FROM ( - (SELECT * FROM articles_hash WHERE author_id = 1) + SELECT * FROM articles_hash WHERE author_id = 1 UNION - (SELECT * FROM articles_hash WHERE author_id = 3)) uu; + SELECT * FROM articles_hash WHERE author_id = 3 +) AS combination +ORDER BY id; DEBUG: Creating router plan DEBUG: Plan is router executable id | author_id | title | word_count ----+-----------+--------------+------------ - 3 | 3 | asternal | 10480 - 43 | 3 | affixal | 12723 - 23 | 3 | abhorring | 6799 - 13 | 3 | aseyev | 2255 - 11 | 1 | alamo | 1347 - 41 | 1 | aznavour | 11814 1 | 1 | arsenous | 9572 + 3 | 3 | asternal | 10480 + 11 | 1 | alamo | 1347 + 13 | 3 | aseyev | 2255 21 | 1 | arcading | 5890 + 23 | 3 | abhorring | 6799 31 | 1 | athwartships | 7271 33 | 3 | autochrome | 8180 + 41 | 1 | aznavour | 11814 + 43 | 3 | affixal | 12723 (10 rows) (SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 1) @@ -881,17 +865,20 @@ DEBUG: Plan is router executable a (1 row) -(SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 1) -EXCEPT -(SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 3); +SELECT * FROM ( + SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 1 + EXCEPT + SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 3 +) AS combination +ORDER BY 1; DEBUG: Creating router plan DEBUG: Plan is router executable left ------ + al + ar at az - ar - al (4 rows) -- union queries are not supported if not router plannable @@ -1379,31 +1366,37 @@ DEBUG: Plan is router executable -- union/difference /intersection with where false -- this query was not originally router plannable, addition of 1=0 -- makes it router plannable -(SELECT * FROM articles_hash WHERE author_id = 1) -UNION -(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0); +SELECT * FROM ( + SELECT * FROM articles_hash WHERE author_id = 1 + UNION + SELECT * FROM articles_hash WHERE author_id = 2 and 1=0 +) AS combination +ORDER BY id; DEBUG: Creating router plan DEBUG: Plan is router executable id | author_id | title | word_count ----+-----------+--------------+------------ - 11 | 1 | alamo | 1347 - 41 | 1 | aznavour | 11814 1 | 1 | arsenous | 9572 + 11 | 1 | alamo | 1347 21 | 1 | arcading | 5890 31 | 1 | athwartships | 7271 + 41 | 1 | aznavour | 11814 (5 rows) -(SELECT * FROM articles_hash WHERE author_id = 1) -EXCEPT -(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0); +SELECT * FROM ( + SELECT * FROM articles_hash WHERE author_id = 1 + EXCEPT + SELECT * FROM articles_hash WHERE author_id = 2 and 1=0 +) AS combination +ORDER BY id; DEBUG: Creating router plan DEBUG: Plan is router executable id | author_id | title | word_count ----+-----------+--------------+------------ 1 | 1 | arsenous | 9572 + 11 | 1 | alamo | 1347 21 | 1 | arcading | 5890 31 | 1 | athwartships | 7271 - 11 | 1 | alamo | 1347 41 | 1 | aznavour | 11814 (5 rows) diff --git a/src/test/regress/input/multi_subquery.source b/src/test/regress/input/multi_subquery.source index ed2dae668..ee93df63a 100644 --- a/src/test/regress/input/multi_subquery.source +++ b/src/test/regress/input/multi_subquery.source @@ -1060,7 +1060,9 @@ FROM subquery_1.user_id, hasdone) AS subquery_top GROUP BY - hasdone; + hasdone +ORDER BY + event_average; -- Union, left join and having subquery pushdown SELECT diff --git a/src/test/regress/output/multi_subquery.source b/src/test/regress/output/multi_subquery.source index 040ca4e7f..58490e03e 100644 --- a/src/test/regress/output/multi_subquery.source +++ b/src/test/regress/output/multi_subquery.source @@ -1021,11 +1021,13 @@ FROM subquery_1.user_id, hasdone) AS subquery_top GROUP BY - hasdone; + hasdone +ORDER BY + event_average; event_average | hasdone --------------------+--------------------- - 4.0000000000000000 | Has not done paying 2.5000000000000000 | Has done paying + 4.0000000000000000 | Has not done paying (2 rows) -- Union, left join and having subquery pushdown diff --git a/src/test/regress/output/multi_subquery_0.source b/src/test/regress/output/multi_subquery_0.source index 205379549..b0f263db8 100644 --- a/src/test/regress/output/multi_subquery_0.source +++ b/src/test/regress/output/multi_subquery_0.source @@ -1021,11 +1021,13 @@ FROM subquery_1.user_id, hasdone) AS subquery_top GROUP BY - hasdone; + hasdone +ORDER BY + event_average; event_average | hasdone --------------------+--------------------- - 4.0000000000000000 | Has not done paying 2.5000000000000000 | Has done paying + 4.0000000000000000 | Has not done paying (2 rows) -- Union, left join and having subquery pushdown diff --git a/src/test/regress/sql/multi_complex_expressions.sql b/src/test/regress/sql/multi_complex_expressions.sql index 4891b2103..5ae818b27 100644 --- a/src/test/regress/sql/multi_complex_expressions.sql +++ b/src/test/regress/sql/multi_complex_expressions.sql @@ -217,8 +217,7 @@ FROM lineitem li JOIN orders o ON li.l_orderkey = o.o_orderkey WHERE li.l_quantity > 25 -ORDER BY - li.l_quantity, li.l_partkey, o.o_custkey +ORDER BY 1, 2, 3 LIMIT 10 OFFSET 20; RESET client_min_messages; diff --git a/src/test/regress/sql/multi_insert_select.sql b/src/test/regress/sql/multi_insert_select.sql index 4e5d8a4c6..53c510f4e 100644 --- a/src/test/regress/sql/multi_insert_select.sql +++ b/src/test/regress/sql/multi_insert_select.sql @@ -235,7 +235,8 @@ FROM (SELECT raw_events_second.user_id AS id, FROM raw_events_first, raw_events_second WHERE raw_events_first.user_id = raw_events_second.user_id) AS foo -GROUP BY id; +GROUP BY id +ORDER BY id; -- subquery one more level depth @@ -252,7 +253,8 @@ FROM (SELECT SUM(raw_events_second.value_4) AS v4, FROM raw_events_first, raw_events_second WHERE raw_events_first.user_id = raw_events_second.user_id - GROUP BY raw_events_second.user_id) AS foo; + GROUP BY raw_events_second.user_id) AS foo +ORDER BY id; -- join between subqueries INSERT INTO agg_events diff --git a/src/test/regress/sql/multi_mx_reference_table.sql b/src/test/regress/sql/multi_mx_reference_table.sql index b612ea91e..84d002e9e 100644 --- a/src/test/regress/sql/multi_mx_reference_table.sql +++ b/src/test/regress/sql/multi_mx_reference_table.sql @@ -195,17 +195,26 @@ WHERE value_1 = 1 OR value_1 = 2; -- set operations are supported -(SELECT * FROM reference_table_test WHERE value_1 = 1) -UNION -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + UNION + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; -(SELECT * FROM reference_table_test WHERE value_1 = 1) -EXCEPT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + EXCEPT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; -(SELECT * FROM reference_table_test WHERE value_1 = 1) -INTERSECT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + INTERSECT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; -- to make the tests more interested for aggregation tests, ingest some more data \c - - - :master_port diff --git a/src/test/regress/sql/multi_mx_router_planner.sql b/src/test/regress/sql/multi_mx_router_planner.sql index 0eb66b353..efeafa7fb 100644 --- a/src/test/regress/sql/multi_mx_router_planner.sql +++ b/src/test/regress/sql/multi_mx_router_planner.sql @@ -202,14 +202,16 @@ SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash_mx WHERE author_id = 1 or author_id = 3 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; -- grouping sets are not supported on multiple shards SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash_mx WHERE author_id = 1 or author_id = 2 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; -- queries which involve functions in FROM clause are supported if it goes to a single worker. SELECT * FROM articles_hash_mx, position('om' in 'Thomas') WHERE author_id = 1; @@ -331,14 +333,12 @@ SELECT max(word_count) -- router plannable union queries are supported -(SELECT * FROM articles_hash_mx WHERE author_id = 1) -UNION -(SELECT * FROM articles_hash_mx WHERE author_id = 3); - SELECT * FROM ( - (SELECT * FROM articles_hash_mx WHERE author_id = 1) + SELECT * FROM articles_hash_mx WHERE author_id = 1 UNION - (SELECT * FROM articles_hash_mx WHERE author_id = 3)) uu; + SELECT * FROM articles_hash_mx WHERE author_id = 3 +) AS combination +ORDER BY id; (SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 1) UNION @@ -348,9 +348,12 @@ UNION INTERSECT (SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 3); -(SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 1) -EXCEPT -(SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 3); +SELECT * FROM ( + SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 1 + EXCEPT + SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 3 +) AS combination +ORDER BY 1; -- union queries are not supported if not router plannable -- there is an inconsistency on shard pruning between diff --git a/src/test/regress/sql/multi_reference_table.sql b/src/test/regress/sql/multi_reference_table.sql index dd8e2d90f..46dcaa3bf 100644 --- a/src/test/regress/sql/multi_reference_table.sql +++ b/src/test/regress/sql/multi_reference_table.sql @@ -228,17 +228,26 @@ WHERE value_1 = 1 OR value_1 = 2; -- set operations are supported -(SELECT * FROM reference_table_test WHERE value_1 = 1) -UNION -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + UNION + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; -(SELECT * FROM reference_table_test WHERE value_1 = 1) -EXCEPT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + EXCEPT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; -(SELECT * FROM reference_table_test WHERE value_1 = 1) -INTERSECT -(SELECT * FROM reference_table_test WHERE value_1 = 3); +SELECT * FROM ( + SELECT * FROM reference_table_test WHERE value_1 = 1 + INTERSECT + SELECT * FROM reference_table_test WHERE value_1 = 3 +) AS combination +ORDER BY value_1; -- to make the tests more interested for aggregation tests, ingest some more data INSERT INTO reference_table_test VALUES (1, 1.0, '1', '2016-12-01'); diff --git a/src/test/regress/sql/multi_router_planner.sql b/src/test/regress/sql/multi_router_planner.sql index b9a72f69c..97defa1e9 100644 --- a/src/test/regress/sql/multi_router_planner.sql +++ b/src/test/regress/sql/multi_router_planner.sql @@ -264,14 +264,16 @@ SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash WHERE author_id = 1 or author_id = 3 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; -- grouping sets are not supported on multiple shards SELECT id, substring(title, 2, 1) AS subtitle, count(*) FROM articles_hash WHERE author_id = 1 or author_id = 2 - GROUP BY GROUPING SETS ((id),(subtitle)); + GROUP BY GROUPING SETS ((id),(subtitle)) + ORDER BY id, subtitle; -- queries which involve functions in FROM clause are supported if it goes to a single worker. SELECT * FROM articles_hash, position('om' in 'Thomas') WHERE author_id = 1; @@ -396,16 +398,14 @@ SELECT max(word_count) WHERE author_id = 1 GROUP BY author_id; - --- router plannable union queries are supported -(SELECT * FROM articles_hash WHERE author_id = 1) -UNION -(SELECT * FROM articles_hash WHERE author_id = 3); +-- router plannable union queries are supported SELECT * FROM ( - (SELECT * FROM articles_hash WHERE author_id = 1) + SELECT * FROM articles_hash WHERE author_id = 1 UNION - (SELECT * FROM articles_hash WHERE author_id = 3)) uu; + SELECT * FROM articles_hash WHERE author_id = 3 +) AS combination +ORDER BY id; (SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 1) UNION @@ -415,9 +415,12 @@ UNION INTERSECT (SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 3); -(SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 1) -EXCEPT -(SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 3); +SELECT * FROM ( + SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 1 + EXCEPT + SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 3 +) AS combination +ORDER BY 1; -- union queries are not supported if not router plannable -- there is an inconsistency on shard pruning between @@ -627,16 +630,24 @@ SELECT a.author_id as first_author, b.word_count as second_word_count FROM articles_hash a, articles_single_shard_hash b WHERE a.author_id = 10 and a.author_id = b.author_id and date_ne_timestamp('1954-04-11', '1954-04-11'::timestamp); + -- union/difference /intersection with where false -- this query was not originally router plannable, addition of 1=0 -- makes it router plannable -(SELECT * FROM articles_hash WHERE author_id = 1) -UNION -(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0); +SELECT * FROM ( + SELECT * FROM articles_hash WHERE author_id = 1 + UNION + SELECT * FROM articles_hash WHERE author_id = 2 and 1=0 +) AS combination +ORDER BY id; + +SELECT * FROM ( + SELECT * FROM articles_hash WHERE author_id = 1 + EXCEPT + SELECT * FROM articles_hash WHERE author_id = 2 and 1=0 +) AS combination +ORDER BY id; -(SELECT * FROM articles_hash WHERE author_id = 1) -EXCEPT -(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0); (SELECT * FROM articles_hash WHERE author_id = 1) INTERSECT