mirror of https://github.com/citusdata/citus.git
Add unambiguous ORDER BY clauses to many tests
Queries which do not specify an order may arbitrarily change output across PostgreSQL versions.pull/1377/head
parent
b9bc3fdada
commit
db11324ac7
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue