diff --git a/src/test/regress/expected/union_gp.out b/src/test/regress/expected/union_gp.out index 6d178d0aa4bd29891f052294065a94980b21597d..f1802632b4caaf814d8bada79bd7a9e03d43bb6d 100644 --- a/src/test/regress/expected/union_gp.out +++ b/src/test/regress/expected/union_gp.out @@ -41,8 +41,8 @@ ERROR: each INTERSECT query must have the same number of columns select 1 a, row_number() over (partition by 'a') union all (select 1 a , 2 b); a | row_number ---+------------ - 1 | 1 1 | 2 + 1 | 1 (2 rows) -- This should preserve domain types @@ -227,9 +227,9 @@ NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' a HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. INSERT INTO T_random SELECT i, i%5 from generate_series(1,30) i; create language plpythonu; -create or replace function count_operator(explain_query text, operator text) returns int as +create or replace function count_operator(query text, operator text) returns int as $$ -rv = plpy.execute(explain_query) +rv = plpy.execute('EXPLAIN ' + query) search_text = operator result = 0 for i in range(len(rv)): @@ -576,11 +576,27 @@ UNION ALL (select d1 from T_constant) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select a1 from T_a1) +UNION ALL +(select b1 from T_b2) +UNION ALL +(select c1 from T_random) +UNION ALL +(select d1 from T_constant) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator(' explain with T_constant (d1, d2) as( @@ -596,11 +612,27 @@ UNION ALL (select d1 from T_constant) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select b1 from T_b2) +UNION ALL +(select a1 from T_a1) +UNION ALL +(select c1 from T_random) +UNION ALL +(select d1 from T_constant) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator(' explain with T_constant (d1, d2) as( @@ -616,11 +648,27 @@ UNION ALL (select d1 from T_constant) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select c1 from T_random) +UNION ALL +(select a1 from T_a1) +UNION ALL +(select b1 from T_b2) +UNION ALL +(select d1 from T_constant) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator(' explain with T_constant (d1, d2) as( @@ -636,11 +684,27 @@ UNION ALL (select b1 from T_b2) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select d1 from T_constant) +UNION ALL +(select c1 from T_random) +UNION ALL +(select a1 from T_a1) +UNION ALL +(select b1 from T_b2) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" -- -- N-ary UNION results -- @@ -858,11 +922,27 @@ UNION (select d1 from T_constant) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select a1 from T_a1) +UNION +(select b1 from T_b2) +UNION +(select c1 from T_random) +UNION +(select d1 from T_constant) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator(' explain with T_constant (d1, d2) as( @@ -878,11 +958,27 @@ UNION (select d1 from T_constant) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select b1 from T_b2) +UNION +(select a1 from T_a1) +UNION +(select c1 from T_random) +UNION +(select d1 from T_constant) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator(' explain with T_constant (d1, d2) as( @@ -898,11 +994,27 @@ UNION (select d1 from T_constant) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select c1 from T_random) +UNION +(select a1 from T_a1) +UNION +(select b1 from T_b2) +UNION +(select d1 from T_constant) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator(' explain with T_constant (d1, d2) as( @@ -918,11 +1030,27 @@ UNION (select b1 from T_b2) order by 1;' , 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 2: explain + ^ +QUERY: EXPLAIN +explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select d1 from T_constant) +UNION +(select c1 from T_random) +UNION +(select a1 from T_a1) +UNION +(select b1 from T_b2) +order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" -- -- Binary UNION ALL results -- @@ -1352,43 +1480,43 @@ UNION ALL SELECT 300, 300) -- -- Binary UNION ALL explain -- -select count_operator('explain (select a1 from T_a1) UNION ALL (select b1 from T_b2) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION ALL (select b1 from T_b2) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select b1 from T_b2) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select b1 from T_b2) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select a1 from T_a1) UNION ALL (select c1 from T_random) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION ALL (select c1 from T_random) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select c1 from T_random) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select c1 from T_random) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select * from T_a1) UNION ALL (select * from T_b2) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION ALL (select * from T_b2) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select * from T_a1) UNION ALL (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION ALL (select * from T_random) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select * from T_b2) UNION ALL (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_b2) UNION ALL (select * from T_random) order by 1;', 'APPEND'); count_operator ---------------- 1 @@ -1400,34 +1528,58 @@ SELECT 100, 100 UNION ALL SELECT 200, 200 UNION ALL SELECT 300, 300) (select a1 from T_a1) UNION ALL (select d1 from T_constant) order by 1;', 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 1: EXPLAIN explain + ^ +QUERY: EXPLAIN explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select a1 from T_a1) UNION ALL (select d1 from T_constant) order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator('explain with T_constant (d1, d2) as( SELECT 100, 100 UNION ALL SELECT 200, 200 UNION ALL SELECT 300, 300) (select d1 from T_constant) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 1: EXPLAIN explain + ^ +QUERY: EXPLAIN explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select d1 from T_constant) UNION ALL (select a1 from T_a1) order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator('explain with T_constant (d1, d2) as( SELECT 100, 100 UNION ALL SELECT 200, 200 UNION ALL SELECT 300, 300) (select c1 from T_random) UNION ALL (select d1 from T_constant) order by 1;', 'APPEND'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain with T_constant (d1, d2) as( +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 1: EXPLAIN explain + ^ +QUERY: EXPLAIN explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION ALL SELECT 200, 200 +UNION ALL SELECT 300, 300) +(select c1 from T_random) UNION ALL (select d1 from T_constant) order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" +select count_operator('with T_constant (d1, d2) as( SELECT 100, 100 UNION ALL SELECT 200, 200 UNION ALL SELECT 300, 300) @@ -1786,43 +1938,43 @@ UNION SELECT 300, 300) -- -- Binary UNION explain -- -select count_operator('explain (select a1 from T_a1) UNION (select b1 from T_b2) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION (select b1 from T_b2) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select b1 from T_b2) UNION (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select b1 from T_b2) UNION (select a1 from T_a1) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select a1 from T_a1) UNION (select c1 from T_random) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION (select c1 from T_random) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select c1 from T_random) UNION (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select c1 from T_random) UNION (select a1 from T_a1) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select * from T_a1) UNION (select * from T_b2) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION (select * from T_b2) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select * from T_a1) UNION (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION (select * from T_random) order by 1;', 'APPEND'); count_operator ---------------- 1 (1 row) -select count_operator('explain (select * from T_b2) UNION (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_b2) UNION (select * from T_random) order by 1;', 'APPEND'); count_operator ---------------- 1 @@ -1834,34 +1986,58 @@ SELECT 100, 100 UNION SELECT 200, 200 UNION SELECT 300, 300) (select a1 from T_a1) UNION (select d1 from T_constant) order by 1;', 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 1: EXPLAIN explain + ^ +QUERY: EXPLAIN explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select a1 from T_a1) UNION (select d1 from T_constant) order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator('explain with T_constant (d1, d2) as( SELECT 100, 100 UNION SELECT 200, 200 UNION SELECT 300, 300) (select d1 from T_constant) UNION (select a1 from T_a1) order by 1;', 'APPEND'); - count_operator ----------------- - 2 -(1 row) - +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 1: EXPLAIN explain + ^ +QUERY: EXPLAIN explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select d1 from T_constant) UNION (select a1 from T_a1) order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" select count_operator('explain with T_constant (d1, d2) as( SELECT 100, 100 UNION SELECT 200, 200 UNION SELECT 300, 300) (select c1 from T_random) UNION (select d1 from T_constant) order by 1;', 'APPEND'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain with T_constant (d1, d2) as( +ERROR: plpy.SPIError: syntax error at or near "explain" +LINE 1: EXPLAIN explain + ^ +QUERY: EXPLAIN explain +with T_constant (d1, d2) as( +SELECT 100, 100 +UNION SELECT 200, 200 +UNION SELECT 300, 300) +(select c1 from T_random) UNION (select d1 from T_constant) order by 1; +CONTEXT: Traceback (most recent call last): + PL/Python function "count_operator", line 2, in + rv = plpy.execute('EXPLAIN ' + query) +PL/Python function "count_operator" +select count_operator('with T_constant (d1, d2) as( SELECT 100, 100 UNION SELECT 200, 200 UNION SELECT 300, 300) diff --git a/src/test/regress/sql/union_gp.sql b/src/test/regress/sql/union_gp.sql index c26c82ef388215244e61b489c0a8f7832bed1bc7..fabb338e9f4abef04b66a89609af0b6cce4b52b4 100644 --- a/src/test/regress/sql/union_gp.sql +++ b/src/test/regress/sql/union_gp.sql @@ -82,9 +82,9 @@ INSERT INTO T_random SELECT i, i%5 from generate_series(1,30) i; create language plpythonu; -create or replace function count_operator(explain_query text, operator text) returns int as +create or replace function count_operator(query text, operator text) returns int as $$ -rv = plpy.execute(explain_query) +rv = plpy.execute('EXPLAIN ' + query) search_text = operator result = 0 for i in range(len(rv)): @@ -389,19 +389,19 @@ UNION ALL SELECT 300, 300) -- Binary UNION ALL explain -- -select count_operator('explain (select a1 from T_a1) UNION ALL (select b1 from T_b2) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION ALL (select b1 from T_b2) order by 1;', 'APPEND'); -select count_operator('explain (select b1 from T_b2) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select b1 from T_b2) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); -select count_operator('explain (select a1 from T_a1) UNION ALL (select c1 from T_random) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION ALL (select c1 from T_random) order by 1;', 'APPEND'); -select count_operator('explain (select c1 from T_random) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select c1 from T_random) UNION ALL (select a1 from T_a1) order by 1;', 'APPEND'); -select count_operator('explain (select * from T_a1) UNION ALL (select * from T_b2) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION ALL (select * from T_b2) order by 1;', 'APPEND'); -select count_operator('explain (select * from T_a1) UNION ALL (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION ALL (select * from T_random) order by 1;', 'APPEND'); -select count_operator('explain (select * from T_b2) UNION ALL (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_b2) UNION ALL (select * from T_random) order by 1;', 'APPEND'); select count_operator('explain with T_constant (d1, d2) as( @@ -424,7 +424,7 @@ UNION ALL SELECT 200, 200 UNION ALL SELECT 300, 300) (select c1 from T_random) UNION ALL (select d1 from T_constant) order by 1;', 'APPEND'); -select count_operator('explain with T_constant (d1, d2) as( +select count_operator('with T_constant (d1, d2) as( SELECT 100, 100 UNION ALL SELECT 200, 200 UNION ALL SELECT 300, 300) @@ -476,19 +476,19 @@ UNION SELECT 300, 300) -- Binary UNION explain -- -select count_operator('explain (select a1 from T_a1) UNION (select b1 from T_b2) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION (select b1 from T_b2) order by 1;', 'APPEND'); -select count_operator('explain (select b1 from T_b2) UNION (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select b1 from T_b2) UNION (select a1 from T_a1) order by 1;', 'APPEND'); -select count_operator('explain (select a1 from T_a1) UNION (select c1 from T_random) order by 1;', 'APPEND'); +select count_operator('(select a1 from T_a1) UNION (select c1 from T_random) order by 1;', 'APPEND'); -select count_operator('explain (select c1 from T_random) UNION (select a1 from T_a1) order by 1;', 'APPEND'); +select count_operator('(select c1 from T_random) UNION (select a1 from T_a1) order by 1;', 'APPEND'); -select count_operator('explain (select * from T_a1) UNION (select * from T_b2) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION (select * from T_b2) order by 1;', 'APPEND'); -select count_operator('explain (select * from T_a1) UNION (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_a1) UNION (select * from T_random) order by 1;', 'APPEND'); -select count_operator('explain (select * from T_b2) UNION (select * from T_random) order by 1;', 'APPEND'); +select count_operator('(select * from T_b2) UNION (select * from T_random) order by 1;', 'APPEND'); select count_operator('explain with T_constant (d1, d2) as( @@ -511,7 +511,7 @@ UNION SELECT 200, 200 UNION SELECT 300, 300) (select c1 from T_random) UNION (select d1 from T_constant) order by 1;', 'APPEND'); -select count_operator('explain with T_constant (d1, d2) as( +select count_operator('with T_constant (d1, d2) as( SELECT 100, 100 UNION SELECT 200, 200 UNION SELECT 300, 300)