diff --git a/src/test/regress/expected/bfv_aggregate.out b/src/test/regress/expected/bfv_aggregate.out deleted file mode 100644 index b8691636d1125fe33034aee7ff4303d902ff4709..0000000000000000000000000000000000000000 --- a/src/test/regress/expected/bfv_aggregate.out +++ /dev/null @@ -1,377 +0,0 @@ ---- ---- Window function with outer references in PARTITION BY/ORDER BY clause ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS x_outer; -NOTICE: table "x_outer" does not exist, skipping -DROP TABLE IF EXISTS y_inner; -NOTICE: table "y_inner" does not exist, skipping --- end_ignore -create table x_outer (a int, b int, c int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create table y_inner (d int, e int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'd' as the Greenplum Database data distribution key for this table. -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 x_outer select i%3, i, i from generate_series(1,10) i; -insert into y_inner select i%3, i from generate_series(1,10) i; -analyze x_outer; -analyze y_inner; --- TEST -select * from x_outer where a in (select row_number() over(partition by a) from y_inner) order by 1, 2; - a | b | c ----+----+---- - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(7 rows) - -select * from x_outer where a in (select rank() over(order by a) from y_inner) order by 1, 2; - a | b | c ----+----+---- - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 -(4 rows) - -select * from x_outer where a not in (select rank() over(order by a) from y_inner) order by 1, 2; - a | b | c ----+---+--- - 0 | 3 | 3 - 0 | 6 | 6 - 0 | 9 | 9 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(6 rows) - -select * from x_outer where exists (select rank() over(order by a) from y_inner where d = a) order by 1, 2; - a | b | c ----+----+---- - 0 | 3 | 3 - 0 | 6 | 6 - 0 | 9 | 9 - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(10 rows) - -select * from x_outer where not exists (select rank() over(order by a) from y_inner where d = a) order by 1, 2; - a | b | c ----+---+--- -(0 rows) - -select * from x_outer where a in (select last_value(d) over(partition by b order by e rows between e preceding and e+1 following) from y_inner) order by 1, 2; - a | b | c ----+----+---- - 0 | 3 | 3 - 0 | 6 | 6 - 0 | 9 | 9 - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(10 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS x_outer; -DROP TABLE IF EXISTS y_inner; --- end_ignore ---- ---- Testing aggregation in a query ---- --- SETUP -create table d (col1 timestamp, col2 int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Greenplum Database data distribution key for this table. -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 d select to_date('2014-01-01', 'YYYY-DD-MM'), generate_series(1,100); --- TEST -select 1, to_char(col1, 'YYYY'), median(col2) from d group by 1, 2; - ?column? | to_char | median -----------+---------+-------- - 1 | 2014 | 50.5 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS d; --- end_ignore ---- ---- Testing if aggregate derived window function produces incorrect results ---- --- SETUP --- start_ignore -drop table if exists toy; -NOTICE: table "toy" does not exist, skipping -drop aggregate mysum1(int4); -ERROR: aggregate mysum1(integer) does not exist -drop aggregate mysum2(int4); -ERROR: aggregate mysum2(integer) does not exist --- end_ignore -create table toy(id,val) as select i,i from generate_series(1,5) i; -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create aggregate mysum1(int4) (sfunc = int4_sum, prefunc=int8pl, stype=bigint); -create aggregate mysum2(int4) (sfunc = int4_sum, stype=bigint); --- TEST -select - id, val, - sum(val) over (w), - mysum1(val) over (w), - mysum2(val) over (w) -from toy -window w as (order by id rows 2 preceding); -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop table if exists toy; -drop aggregate mysum1(int4); -drop aggregate mysum2(int4); --- end_ignore ---- ---- Error executing for aggregate with anyarry as return type ---- --- SETUP -CREATE OR REPLACE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS -'select $1 || $2' LANGUAGE SQL; -CREATE OR REPLACE FUNCTION ffp(anyarray) RETURNS anyarray AS -'select $1' LANGUAGE SQL; -CREATE AGGREGATE myaggp20a(BASETYPE = anyelement, SFUNC = tfp, - STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}'); --- Adding a sql function to sory the array -CREATE OR REPLACE FUNCTION array_sort (ANYARRAY) -RETURNS ANYARRAY LANGUAGE SQL -AS $$ -SELECT ARRAY(SELECT unnest($1) ORDER BY 1) -$$; -create temp table t(f1 int, f2 int[], f3 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. --- TEST -insert into t values(1,array[1],'a'); -insert into t values(1,array[11],'b'); -insert into t values(1,array[111],'c'); -insert into t values(2,array[2],'a'); -insert into t values(2,array[22],'b'); -insert into t values(2,array[222],'c'); -insert into t values(3,array[3],'a'); -insert into t values(3,array[3],'b'); -select f3, array_sort(myaggp20a(f1)) from t group by f3 order by f3; - f3 | array_sort -----+------------ - a | {1,2,3} - b | {1,2,3} - c | {1,2} -(3 rows) - --- CLEANUP --- start_ignore -drop table if exists t; -drop function array_sort (ANYARRAY) cascade; -drop function tfp(anyarray,anyelement) cascade; -NOTICE: drop cascades to function myaggp20a(anyelement) -drop function ffp(anyarray) cascade; --- end_ignore --- start_ignore --- start_ignore -drop language if exists plpythonu; -create language plpythonu; --- end_ignore -create or replace function count_operator(explain_query text, operator text) returns int as -$$ -rv = plpy.execute(explain_query) -search_text = operator -result = 0 -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = result+1 -return result -$$ -language plpythonu; ---- ---- Testing adding a traceflag to favor multi-stage aggregation ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS multi_stage_test; -NOTICE: table "multi_stage_test" does not exist, skipping --- end_ignore -create table multi_stage_test(a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -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 multi_stage_test select i, i%4 from generate_series(1,10) i; -analyze multi_stage_test; --- TEST --- start_ignore -set optimizer_segments=2; -set optimizer_prefer_multistage_agg = on; --- end_ignore -select count_operator('explain select count(*) from multi_stage_test group by b;','GroupAggregate'); - count_operator ----------------- - 0 -(1 row) - --- start_ignore -set optimizer_prefer_multistage_agg = off; --- end_ignore -select count_operator('explain select count(*) from multi_stage_test group by b;','GroupAggregate'); - count_operator ----------------- - 0 -(1 row) - ---CLEANUP --- start_ignore -DROP TABLE IF EXISTS multi_stage_test; -reset optimizer_segments; -set optimizer_prefer_multistage_agg = off; --- end_ignore ---- ---- Testing not picking HashAgg for aggregates without preliminary functions ---- --- SETUP --- start_ignore -SET optimizer_disable_missing_stats_collection=on; -DROP TABLE IF EXISTS attribute_table; -NOTICE: table "attribute_table" does not exist, skipping --- end_ignore -CREATE TABLE attribute_table (product_id integer, attribute_id integer,attribute text, attribute2 text,attribute_ref_lists text,short_name text,attribute6 text,attribute5 text,measure double precision,unit character varying(60)) DISTRIBUTED BY (product_id ,attribute_id); --- create the transition function -CREATE OR REPLACE FUNCTION do_concat(text,text) -RETURNS text ---concatenates 2 strings -AS 'SELECT CASE WHEN $1 IS NULL THEN $2 -WHEN $2 IS NULL THEN $1 -ELSE $1 || $2 END;' - LANGUAGE SQL - IMMUTABLE - RETURNS NULL ON NULL INPUT; --- UDA definition. No PREFUNC exists --- start_ignore -DROP AGGREGATE IF EXISTS concat(text); -NOTICE: aggregate concat(text) does not exist, skipping --- end_ignore -CREATE AGGREGATE concat(text) ( - --text/string concatenation - SFUNC = do_concat, --Function to call for each string that builds the aggregate - STYPE = text,--FINALFUNC=final_func, --Function to call after everything has been aggregated - INITCOND = '' --Initialize as an empty string when starting -); --- TEST --- cook some stats --- start_ignore -set allow_system_table_mods='DML'; --- end_ignore -UPDATE pg_class set reltuples=524592::real, relpages=2708::integer where oid = 'attribute_table'::regclass; -select count_operator('explain select product_id,concat(E''#attribute_''||attribute_id::varchar||E'':''||attribute) as attr FROM attribute_table GROUP BY product_id;','HashAggregate'); - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS attribute_table; -DROP AGGREGATE IF EXISTS concat(text); -drop function do_concat(text,text) cascade; -SET optimizer_disable_missing_stats_collection=off; --- end_ignore ---- ---- Testing fallback to planner when the agg used in window does not have either prelim or inverse prelim function. ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS foo; -NOTICE: table "foo" does not exist, skipping --- end_ignore -create table foo(a int, b text) distributed by (a); --- TEST -insert into foo values (1,'aaa'), (2,'bbb'), (3,'ccc'); --- should fall back -select string_agg(b) over (partition by a) from foo order by 1; - string_agg ------------- - aaa - bbb - ccc -(3 rows) - -select string_agg(b) over (partition by a,b) from foo order by 1; - string_agg ------------- - aaa - bbb - ccc -(3 rows) - --- should not fall back -select max(b) over (partition by a) from foo order by 1; - max ------ - aaa - bbb - ccc -(3 rows) - -select count_operator('explain select max(b) over (partition by a) from foo order by 1;', 'Table Scan'); - count_operator ----------------- - 0 -(1 row) - --- fall back -select string_agg(b) over (partition by a+1) from foo order by 1; - string_agg ------------- - aaa - bbb - ccc -(3 rows) - -select string_agg(b || 'txt') over (partition by a) from foo order by 1; - string_agg ------------- - aaatxt - bbbtxt - ccctxt -(3 rows) - -select string_agg(b || 'txt') over (partition by a+1) from foo order by 1; - string_agg ------------- - aaatxt - bbbtxt - ccctxt -(3 rows) - --- fall back and planner's plan produces unsupported execution -select string_agg(b) over (partition by a order by a) from foo order by 1; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions -select string_agg(b || 'txt') over (partition by a,b order by a,b) from foo order by 1; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions -select '1' || string_agg(b) over (partition by a+1 order by a+1) from foo; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop function count_operator(text,text); -DROP TABLE IF EXISTS foo; -drop function if exists count_operator(explain_query text, operator text); -NOTICE: function count_operator(text,text) does not exist, skipping -drop language if exists plpythonu; --- end_ignore diff --git a/src/test/regress/expected/bfv_aggregate_optimizer.out b/src/test/regress/expected/bfv_aggregate_optimizer.out deleted file mode 100644 index 8990e28dbf7f22be4c273a203bf5df74c11536ab..0000000000000000000000000000000000000000 --- a/src/test/regress/expected/bfv_aggregate_optimizer.out +++ /dev/null @@ -1,376 +0,0 @@ ---- ---- Window function with outer references in PARTITION BY/ORDER BY clause ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS x_outer; -NOTICE: table "x_outer" does not exist, skipping -DROP TABLE IF EXISTS y_inner; -NOTICE: table "y_inner" does not exist, skipping --- end_ignore -create table x_outer (a int, b int, c int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create table y_inner (d int, e int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'd' as the Greenplum Database data distribution key for this table. -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 x_outer select i%3, i, i from generate_series(1,10) i; -insert into y_inner select i%3, i from generate_series(1,10) i; -analyze x_outer; -analyze y_inner; --- TEST -select * from x_outer where a in (select row_number() over(partition by a) from y_inner) order by 1, 2; - a | b | c ----+----+---- - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(7 rows) - -select * from x_outer where a in (select rank() over(order by a) from y_inner) order by 1, 2; - a | b | c ----+----+---- - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 -(4 rows) - -select * from x_outer where a not in (select rank() over(order by a) from y_inner) order by 1, 2; - a | b | c ----+---+--- - 0 | 3 | 3 - 0 | 6 | 6 - 0 | 9 | 9 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(6 rows) - -select * from x_outer where exists (select rank() over(order by a) from y_inner where d = a) order by 1, 2; - a | b | c ----+----+---- - 0 | 3 | 3 - 0 | 6 | 6 - 0 | 9 | 9 - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(10 rows) - -select * from x_outer where not exists (select rank() over(order by a) from y_inner where d = a) order by 1, 2; - a | b | c ----+---+--- -(0 rows) - -select * from x_outer where a in (select last_value(d) over(partition by b order by e rows between e preceding and e+1 following) from y_inner) order by 1, 2; - a | b | c ----+----+---- - 0 | 3 | 3 - 0 | 6 | 6 - 0 | 9 | 9 - 1 | 1 | 1 - 1 | 4 | 4 - 1 | 7 | 7 - 1 | 10 | 10 - 2 | 2 | 2 - 2 | 5 | 5 - 2 | 8 | 8 -(10 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS x_outer; -DROP TABLE IF EXISTS y_inner; --- end_ignore ---- ---- Testing aggregation in a query ---- --- SETUP -create table d (col1 timestamp, col2 int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Greenplum Database data distribution key for this table. -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 d select to_date('2014-01-01', 'YYYY-DD-MM'), generate_series(1,100); --- TEST -select 1, to_char(col1, 'YYYY'), median(col2) from d group by 1, 2; - ?column? | to_char | median -----------+---------+-------- - 1 | 2014 | 50.5 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS d; --- end_ignore ---- ---- Testing if aggregate derived window function produces incorrect results ---- --- SETUP --- start_ignore -drop table if exists toy; -NOTICE: table "toy" does not exist, skipping -drop aggregate mysum1(int4); -ERROR: aggregate mysum1(integer) does not exist -drop aggregate mysum2(int4); -ERROR: aggregate mysum2(integer) does not exist --- end_ignore -create table toy(id,val) as select i,i from generate_series(1,5) i; -NOTICE: Table doesn't have 'distributed by' clause. Creating a NULL policy entry. -create aggregate mysum1(int4) (sfunc = int4_sum, prefunc=int8pl, stype=bigint); -create aggregate mysum2(int4) (sfunc = int4_sum, stype=bigint); --- TEST -select - id, val, - sum(val) over (w), - mysum1(val) over (w), - mysum2(val) over (w) -from toy -window w as (order by id rows 2 preceding); -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop table if exists toy; -drop aggregate mysum1(int4); -drop aggregate mysum2(int4); --- end_ignore ---- ---- Error executing for aggregate with anyarry as return type ---- --- SETUP -CREATE OR REPLACE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS -'select $1 || $2' LANGUAGE SQL; -CREATE OR REPLACE FUNCTION ffp(anyarray) RETURNS anyarray AS -'select $1' LANGUAGE SQL; -CREATE AGGREGATE myaggp20a(BASETYPE = anyelement, SFUNC = tfp, - STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}'); --- Adding a sql function to sory the array -CREATE OR REPLACE FUNCTION array_sort (ANYARRAY) -RETURNS ANYARRAY LANGUAGE SQL -AS $$ -SELECT ARRAY(SELECT unnest($1) ORDER BY 1) -$$; -create temp table t(f1 int, f2 int[], f3 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. --- TEST -insert into t values(1,array[1],'a'); -insert into t values(1,array[11],'b'); -insert into t values(1,array[111],'c'); -insert into t values(2,array[2],'a'); -insert into t values(2,array[22],'b'); -insert into t values(2,array[222],'c'); -insert into t values(3,array[3],'a'); -insert into t values(3,array[3],'b'); -select f3, array_sort(myaggp20a(f1)) from t group by f3 order by f3; - f3 | array_sort -----+------------ - a | {1,2,3} - b | {1,2,3} - c | {1,2} -(3 rows) - --- CLEANUP --- start_ignore -drop table if exists t; -drop function array_sort (ANYARRAY) cascade; -drop function tfp(anyarray,anyelement) cascade; -NOTICE: drop cascades to function myaggp20a(anyelement) -drop function ffp(anyarray) cascade; --- end_ignore --- start_ignore --- start_ignore -drop language if exists plpythonu; -create language plpythonu; --- end_ignore -create or replace function count_operator(explain_query text, operator text) returns int as -$$ -rv = plpy.execute(explain_query) -search_text = operator -result = 0 -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = result+1 -return result -$$ -language plpythonu; ---- ---- Testing adding a traceflag to favor multi-stage aggregation ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS multi_stage_test; -NOTICE: table "multi_stage_test" does not exist, skipping --- end_ignore -create table multi_stage_test(a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -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 multi_stage_test select i, i%4 from generate_series(1,10) i; -analyze multi_stage_test; --- TEST --- start_ignore -set optimizer_segments=2; -set optimizer_prefer_multistage_agg = on; --- end_ignore -select count_operator('explain select count(*) from multi_stage_test group by b;','GroupAggregate'); - count_operator ----------------- - 2 -(1 row) - --- start_ignore -set optimizer_prefer_multistage_agg = off; --- end_ignore -select count_operator('explain select count(*) from multi_stage_test group by b;','GroupAggregate'); - count_operator ----------------- - 1 -(1 row) - ---CLEANUP --- start_ignore -DROP TABLE IF EXISTS multi_stage_test; -reset optimizer_segments; -set optimizer_prefer_multistage_agg = off; --- end_ignore ---- ---- Testing not picking HashAgg for aggregates without preliminary functions ---- --- SETUP --- start_ignore -SET optimizer_disable_missing_stats_collection=on; -DROP TABLE IF EXISTS attribute_table; -NOTICE: table "attribute_table" does not exist, skipping --- end_ignore -CREATE TABLE attribute_table (product_id integer, attribute_id integer,attribute text, attribute2 text,attribute_ref_lists text,short_name text,attribute6 text,attribute5 text,measure double precision,unit character varying(60)) DISTRIBUTED BY (product_id ,attribute_id); --- create the transition function -CREATE OR REPLACE FUNCTION do_concat(text,text) -RETURNS text ---concatenates 2 strings -AS 'SELECT CASE WHEN $1 IS NULL THEN $2 -WHEN $2 IS NULL THEN $1 -ELSE $1 || $2 END;' - LANGUAGE SQL - IMMUTABLE - RETURNS NULL ON NULL INPUT; --- UDA definition. No PREFUNC exists --- start_ignore -DROP AGGREGATE IF EXISTS concat(text); -NOTICE: aggregate concat(text) does not exist, skipping --- end_ignore -CREATE AGGREGATE concat(text) ( - --text/string concatenation - SFUNC = do_concat, --Function to call for each string that builds the aggregate - STYPE = text,--FINALFUNC=final_func, --Function to call after everything has been aggregated - INITCOND = '' --Initialize as an empty string when starting -); --- TEST --- cook some stats --- start_ignore -set allow_system_table_mods='DML'; --- end_ignore -UPDATE pg_class set reltuples=524592::real, relpages=2708::integer where oid = 'attribute_table'::regclass; -select count_operator('explain select product_id,concat(E''#attribute_''||attribute_id::varchar||E'':''||attribute) as attr FROM attribute_table GROUP BY product_id;','HashAggregate'); - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS attribute_table; -DROP AGGREGATE IF EXISTS concat(text); -drop function do_concat(text,text) cascade; -SET optimizer_disable_missing_stats_collection=off; --- end_ignore ---- ---- Testing fallback to planner when the agg used in window does not have either prelim or inverse prelim function. ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS foo; -NOTICE: table "foo" does not exist, skipping --- end_ignore -create table foo(a int, b text) distributed by (a); --- TEST -insert into foo values (1,'aaa'), (2,'bbb'), (3,'ccc'); --- should fall back -select string_agg(b) over (partition by a) from foo order by 1; - string_agg ------------- - aaa - bbb - ccc -(3 rows) - -select string_agg(b) over (partition by a,b) from foo order by 1; - string_agg ------------- - aaa - bbb - ccc -(3 rows) - --- should not fall back -select max(b) over (partition by a) from foo order by 1; - max ------ - aaa - bbb - ccc -(3 rows) - -select count_operator('explain select max(b) over (partition by a) from foo order by 1;', 'Table Scan'); - count_operator ----------------- - 1 -(1 row) - --- fall back -select string_agg(b) over (partition by a+1) from foo order by 1; - string_agg ------------- - aaa - bbb - ccc -(3 rows) - -select string_agg(b || 'txt') over (partition by a) from foo order by 1; - string_agg ------------- - aaatxt - bbbtxt - ccctxt -(3 rows) - -select string_agg(b || 'txt') over (partition by a+1) from foo order by 1; - string_agg ------------- - aaatxt - bbbtxt - ccctxt -(3 rows) - --- fall back and planner's plan produces unsupported execution -select string_agg(b) over (partition by a order by a) from foo order by 1; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions -select string_agg(b || 'txt') over (partition by a,b order by a,b) from foo order by 1; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions -select '1' || string_agg(b) over (partition by a+1 order by a+1) from foo; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop function count_operator(text,text); -DROP TABLE IF EXISTS foo; -drop function if exists count_operator(explain_query text, operator text); -NOTICE: function count_operator(text,text) does not exist, skipping -drop language if exists plpythonu; --- end_ignore diff --git a/src/test/regress/expected/bfv_olap.out b/src/test/regress/expected/bfv_olap.out deleted file mode 100644 index 214751eac120d7d07cd3e330a946e1071367439d..0000000000000000000000000000000000000000 --- a/src/test/regress/expected/bfv_olap.out +++ /dev/null @@ -1,453 +0,0 @@ ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- --- SETUP --- start_ignore -drop table if exists toy; -NOTICE: table "toy" does not exist, skipping -drop aggregate if exists mysum1(int4); -NOTICE: aggregate mysum1(int4) does not exist, skipping -drop aggregate if exists mysum2(int4); -NOTICE: aggregate mysum2(int4) does not exist, skipping --- end_ignore -create table toy(id,val) as select i,i from generate_series(1,5) i; -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create aggregate mysum1(int4) (sfunc = int4_sum, prefunc=int8pl, stype=bigint); -create aggregate mysum2(int4) (sfunc = int4_sum, stype=bigint); --- TEST -select id, val, sum(val) over (w), mysum1(val) over (w), mysum2(val) over (w) from toy window w as (order by id rows 2 preceding); -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop aggregate if exists mysum1(int4); -drop aggregate if exists mysum2(int4); -drop table if exists toy; --- end_ignore ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- --- SETUP --- start_ignore -drop type if exists ema_type cascade; -NOTICE: type "ema_type" does not exist, skipping -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -ERROR: type "ema_type" does not exist -drop function if exists ema_fin(t ema_type) cascade; -ERROR: type "ema_type" does not exist -drop aggregate if exists ema(float, float); -NOTICE: aggregate ema(pg_catalog.float8,pg_catalog.float8) does not exist, skipping -drop table if exists ema_test cascade; -NOTICE: table "ema_test" does not exist, skipping --- end_ignore -create type ema_type as (x float, e float); -create function ema_adv(t ema_type, v float, x float) - returns ema_type - as $$ - begin - if t.e is null then - t.e = v; - t.x = x; - else - if t.x != x then - raise exception 'ema smoothing x may not vary'; - end if; - t.e = t.e + (v - t.e) * t.x; - end if; - return t; - end; - $$ language plpgsql; -create function ema_fin(t ema_type) - returns float - as $$ - begin - return t.e; - end; - $$ language plpgsql; -create aggregate ema(float, float) ( - sfunc = ema_adv, - stype = ema_type, - finalfunc = ema_fin, - initcond = '(,)'); -create table ema_test (k int, v float ) distributed by (k); -insert into ema_test select i, 4*random() + 10.0*(1+cos(radians(i*5))) from generate_series(0,19) i(i); --- TEST -select k, v, ema(v, 0.9) over (order by k rows between unbounded preceding and current row) from ema_test order by k; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop table if exists ema_test cascade; -drop aggregate if exists ema(float, float); -drop function if exists ema_fin(t ema_type) cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop type if exists ema_type cascade; --- end_ignore ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- --- SETUP --- start_ignore -drop type if exists ema_type cascade; -NOTICE: type "ema_type" does not exist, skipping -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -ERROR: type "ema_type" does not exist -drop function if exists ema_fin(t ema_type) cascade; -ERROR: type "ema_type" does not exist -drop aggregate if exists ema(float, float); -NOTICE: aggregate ema(pg_catalog.float8,pg_catalog.float8) does not exist, skipping -drop table if exists ema_test cascade; -NOTICE: table "ema_test" does not exist, skipping --- end_ignore -create type ema_type as (x float, e float); -create function ema_adv(t ema_type, v float, x float) - returns ema_type - as $$ - begin - if t.e is null then - t.e = v; - t.x = x; - else - if t.x != x then - raise exception 'ema smoothing x may not vary'; - end if; - t.e = t.e + (v - t.e) * t.x; - end if; - return t; - end; - $$ language plpgsql; -create function ema_fin(t ema_type) - returns float - as $$ - begin - return t.e; - end; - $$ language plpgsql; -create aggregate ema(float, float) ( - sfunc = ema_adv, - stype = ema_type, - finalfunc = ema_fin, - initcond = '(,)'); -create table ema_test (k int, v float ) distributed by (k); -insert into ema_test select i, 4*random() + 10.0*(1+cos(radians(i*5))) from generate_series(0,19) i(i); --- TEST -select k, v, ema(v, 0.9) over (order by k) from ema_test order by k; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop table if exists ema_test cascade; -drop aggregate if exists ema(float, float); -drop function if exists ema_fin(t ema_type) cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop type if exists ema_type cascade; --- end_ignore ---- ---- Test with/without group by ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; -NOTICE: table "r" does not exist, skipping --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); -NOTICE: updating distribution policy to match new primary key -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "r_pkey" for table "r" ---TEST -SELECT MAX(a) AS m FROM r GROUP BY b ORDER BY m; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY a ORDER BY m; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY b; - m ---- -(0 rows) - - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore ---- ---- ORDER BY clause includes some grouping column or not ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; -NOTICE: table "r" does not exist, skipping --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); -NOTICE: updating distribution policy to match new primary key -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "r_pkey" for table "r" ---TEST -SELECT MAX(a) AS m FROM R GROUP BY b ORDER BY m,b; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM R GROUP BY b,e ORDER BY m,b,e; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM R GROUP BY b,e ORDER BY m; - m ---- -(0 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore ---- ---- ORDER BY 1 or more columns ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; -NOTICE: table "r" does not exist, skipping --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); -NOTICE: updating distribution policy to match new primary key -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "r_pkey" for table "r" ---TEST -SELECT MAX(a),d,e AS m FROM r GROUP BY b,d,e ORDER BY m,e,d; - max | d | m ------+---+--- -(0 rows) - -SELECT MIN(a),d,e AS m FROM r GROUP BY b,e,d ORDER BY e,d; - min | d | m ------+---+--- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY b,c,d,e ORDER BY e,d; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY b,e ORDER BY e; - m ---- -(0 rows) - -SELECT MAX(e) AS m FROM r GROUP BY b ORDER BY m; - m ---- -(0 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore ---- ---- ORDER BY clause includes some grouping column or not ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS dm_calendar; -NOTICE: table "dm_calendar" does not exist, skipping --- end_ignore -CREATE TABLE dm_calendar ( - calendar_id bigint NOT NULL, - date_name character varying(200), - date_name_cn character varying(200), - calendar_date date, - current_day numeric(10,0), - month_id numeric(10,0), - month_name character varying(200), - month_name_cn character varying(200), - month_name_short character varying(200), - month_name_short_cn character varying(200), - days_in_month numeric(10,0), - first_of_month numeric(10,0), - last_month_id numeric(10,0), - month_end numeric(10,0), - quarter_id numeric(10,0), - quarter_name character varying(200), - quarter_name_cn character varying(200), - quarter_name_short character varying(200), - quarter_name_short_cn character varying(200), - year_id numeric(10,0), - year_name character varying(200), - year_name_cn character varying(200), - description character varying(500), - create_date timestamp without time zone, - month_week_num character varying(100), - month_week_begin character varying(100), - month_week_end character varying(100), - half_year character varying(100), - weekend_flag character varying(100), - holidays_flag character varying(100), - workday_flag character varying(100), - month_number numeric(10,0) -) DISTRIBUTED BY (calendar_id); -ALTER TABLE ONLY dm_calendar ADD CONSTRAINT dm_calendar_pkey PRIMARY KEY (calendar_id); -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "dm_calendar_pkey" for table "dm_calendar" ---TEST -SELECT "year_id" as id , min("year_name") as a from (select "year_id" as "year_id" , min("year_name") as "year_name" from "dm_calendar" group by "year_id") "dm_calendar3" group by "year_id" order by a ASC ; - id | a -----+--- -(0 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS dm_calendar; --- end_ignore ---- ---- Test with/without group by with primary key as dist key ---- --- SETUP --- start_ignore -drop table if exists t; -NOTICE: table "t" does not exist, skipping --- end_ignore -create table t -( - a int NOT NULL, - b int, - c character varying(200), - d numeric(10,0), - e date -) distributed by (b); -alter table t ADD CONSTRAINT pkey primary key (b); -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "t_pkey" for table "t" --- TEST -SELECT MAX(a) AS m FROM t GROUP BY b ORDER BY m; - m ---- -(0 rows) - --- CLEANUP --- start_ignore -drop table if exists t; --- end_ignore ---- ---- Passing through distribution matching type in default implementation ---- --- SETUP --- start_ignore -drop table if exists customer; -NOTICE: table "customer" does not exist, skipping -drop table if exists sale; -NOTICE: table "sale" does not exist, skipping --- end_ignore -create table customer -( - cn int not null, - cname text not null, - cloc text, - primary key (cn) -) distributed by (cn); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "customer_pkey" for table "customer" -insert into customer values - ( 1, 'Macbeth', 'Inverness'), - ( 2, 'Duncan', 'Forres'), - ( 3, 'Lady Macbeth', 'Inverness'), - ( 4, 'Witches, Inc', 'Lonely Heath'); -create table sale -( - cn int not null, - vn int not null, - pn int not null, - dt date not null, - qty int not null, - prc float not null, - primary key (cn, vn, pn) -) distributed by (cn,vn,pn); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "sale_pkey" for table "sale" -insert into sale values - ( 2, 40, 100, '1401-1-1', 1100, 2400), - ( 1, 10, 200, '1401-3-1', 1, 0), - ( 3, 40, 200, '1401-4-1', 1, 0), - ( 1, 20, 100, '1401-5-1', 1, 0), - ( 1, 30, 300, '1401-5-2', 1, 0), - ( 1, 50, 400, '1401-6-1', 1, 0), - ( 2, 50, 400, '1401-6-1', 1, 0), - ( 1, 30, 500, '1401-6-1', 12, 5), - ( 3, 30, 500, '1401-6-1', 12, 5), - ( 3, 30, 600, '1401-6-1', 12, 5), - ( 4, 40, 700, '1401-6-1', 1, 1), - ( 4, 40, 800, '1401-6-1', 1, 1); - --- TEST -select cname, -rank() over (partition by sale.cn order by vn) -from sale, customer -where sale.cn = customer.cn -order by 1, 2; - cname | rank ---------------+------ - Duncan | 1 - Duncan | 2 - Lady Macbeth | 1 - Lady Macbeth | 1 - Lady Macbeth | 3 - Macbeth | 1 - Macbeth | 2 - Macbeth | 3 - Macbeth | 3 - Macbeth | 5 - Witches, Inc | 1 - Witches, Inc | 1 -(12 rows) - --- CLEANUP --- start_ignore -drop table if exists customer; -drop table if exists sale; --- end_ignore ---- ---- Optimzier query crashing for logical window with no window functions ---- --- SETUP -create table mpp23240(a int, b int, c int, d int, e int, f int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. --- TEST -select a, b, - case 1 - when 10 then - sum(c) over(partition by a) - when 20 then - sum(d) over(partition by a) - else - 5 - end as sum1 -from (select * from mpp23240 where f > 10) x; - a | b | sum1 ----+---+------ -(0 rows) - --- CLEANUP --- start_ignore -drop table mpp23240; --- end_ignore diff --git a/src/test/regress/expected/bfv_olap_optimizer.out b/src/test/regress/expected/bfv_olap_optimizer.out deleted file mode 100644 index 0e19e83bd030e88142dc5c14a566e3886a3a5138..0000000000000000000000000000000000000000 --- a/src/test/regress/expected/bfv_olap_optimizer.out +++ /dev/null @@ -1,452 +0,0 @@ ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- --- SETUP --- start_ignore -drop table if exists toy; -NOTICE: table "toy" does not exist, skipping -drop aggregate if exists mysum1(int4); -NOTICE: aggregate mysum1(int4) does not exist, skipping -drop aggregate if exists mysum2(int4); -NOTICE: aggregate mysum2(int4) does not exist, skipping --- end_ignore -create table toy(id,val) as select i,i from generate_series(1,5) i; -NOTICE: Table doesn't have 'distributed by' clause. Creating a NULL policy entry. -create aggregate mysum1(int4) (sfunc = int4_sum, prefunc=int8pl, stype=bigint); -create aggregate mysum2(int4) (sfunc = int4_sum, stype=bigint); --- TEST -select id, val, sum(val) over (w), mysum1(val) over (w), mysum2(val) over (w) from toy window w as (order by id rows 2 preceding); -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop aggregate if exists mysum1(int4); -drop aggregate if exists mysum2(int4); -drop table if exists toy; --- end_ignore ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- --- SETUP --- start_ignore -drop type if exists ema_type cascade; -NOTICE: type "ema_type" does not exist, skipping -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -ERROR: type "ema_type" does not exist -drop function if exists ema_fin(t ema_type) cascade; -ERROR: type "ema_type" does not exist -drop aggregate if exists ema(float, float); -NOTICE: aggregate ema(pg_catalog.float8,pg_catalog.float8) does not exist, skipping -drop table if exists ema_test cascade; -NOTICE: table "ema_test" does not exist, skipping --- end_ignore -create type ema_type as (x float, e float); -create function ema_adv(t ema_type, v float, x float) - returns ema_type - as $$ - begin - if t.e is null then - t.e = v; - t.x = x; - else - if t.x != x then - raise exception 'ema smoothing x may not vary'; - end if; - t.e = t.e + (v - t.e) * t.x; - end if; - return t; - end; - $$ language plpgsql; -create function ema_fin(t ema_type) - returns float - as $$ - begin - return t.e; - end; - $$ language plpgsql; -create aggregate ema(float, float) ( - sfunc = ema_adv, - stype = ema_type, - finalfunc = ema_fin, - initcond = '(,)'); -create table ema_test (k int, v float ) distributed by (k); -insert into ema_test select i, 4*random() + 10.0*(1+cos(radians(i*5))) from generate_series(0,19) i(i); --- TEST -select k, v, ema(v, 0.9) over (order by k rows between unbounded preceding and current row) from ema_test order by k; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop table if exists ema_test cascade; -drop aggregate if exists ema(float, float); -drop function if exists ema_fin(t ema_type) cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop type if exists ema_type cascade; --- end_ignore ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- --- SETUP --- start_ignore -drop type if exists ema_type cascade; -NOTICE: type "ema_type" does not exist, skipping -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -ERROR: type "ema_type" does not exist -drop function if exists ema_fin(t ema_type) cascade; -ERROR: type "ema_type" does not exist -drop aggregate if exists ema(float, float); -NOTICE: aggregate ema(pg_catalog.float8,pg_catalog.float8) does not exist, skipping -drop table if exists ema_test cascade; -NOTICE: table "ema_test" does not exist, skipping --- end_ignore -create type ema_type as (x float, e float); -create function ema_adv(t ema_type, v float, x float) - returns ema_type - as $$ - begin - if t.e is null then - t.e = v; - t.x = x; - else - if t.x != x then - raise exception 'ema smoothing x may not vary'; - end if; - t.e = t.e + (v - t.e) * t.x; - end if; - return t; - end; - $$ language plpgsql; -create function ema_fin(t ema_type) - returns float - as $$ - begin - return t.e; - end; - $$ language plpgsql; -create aggregate ema(float, float) ( - sfunc = ema_adv, - stype = ema_type, - finalfunc = ema_fin, - initcond = '(,)'); -create table ema_test (k int, v float ) distributed by (k); -insert into ema_test select i, 4*random() + 10.0*(1+cos(radians(i*5))) from generate_series(0,19) i(i); --- TEST -select k, v, ema(v, 0.9) over (order by k) from ema_test order by k; -ERROR: aggregate functions with no prelimfn or invprelimfn are not yet supported as window functions --- CLEANUP --- start_ignore -drop table if exists ema_test cascade; -drop aggregate if exists ema(float, float); -drop function if exists ema_fin(t ema_type) cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop type if exists ema_type cascade; --- end_ignore ---- ---- Test with/without group by ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; -NOTICE: table "r" does not exist, skipping --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); -NOTICE: updating distribution policy to match new primary key -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "r_pkey" for table "r" ---TEST -SELECT MAX(a) AS m FROM r GROUP BY b ORDER BY m; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY a ORDER BY m; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY b; - m ---- -(0 rows) - - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore ---- ---- ORDER BY clause includes some grouping column or not ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; -NOTICE: table "r" does not exist, skipping --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); -NOTICE: updating distribution policy to match new primary key -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "r_pkey" for table "r" ---TEST -SELECT MAX(a) AS m FROM R GROUP BY b ORDER BY m,b; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM R GROUP BY b,e ORDER BY m,b,e; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM R GROUP BY b,e ORDER BY m; - m ---- -(0 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore ---- ---- ORDER BY 1 or more columns ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; -NOTICE: table "r" does not exist, skipping --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); -NOTICE: updating distribution policy to match new primary key -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "r_pkey" for table "r" ---TEST -SELECT MAX(a),d,e AS m FROM r GROUP BY b,d,e ORDER BY m,e,d; - max | d | m ------+---+--- -(0 rows) - -SELECT MIN(a),d,e AS m FROM r GROUP BY b,e,d ORDER BY e,d; - min | d | m ------+---+--- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY b,c,d,e ORDER BY e,d; - m ---- -(0 rows) - -SELECT MAX(a) AS m FROM r GROUP BY b,e ORDER BY e; - m ---- -(0 rows) - -SELECT MAX(e) AS m FROM r GROUP BY b ORDER BY m; - m ---- -(0 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore ---- ---- ORDER BY clause includes some grouping column or not ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS dm_calendar; -NOTICE: table "dm_calendar" does not exist, skipping --- end_ignore -CREATE TABLE dm_calendar ( - calendar_id bigint NOT NULL, - date_name character varying(200), - date_name_cn character varying(200), - calendar_date date, - current_day numeric(10,0), - month_id numeric(10,0), - month_name character varying(200), - month_name_cn character varying(200), - month_name_short character varying(200), - month_name_short_cn character varying(200), - days_in_month numeric(10,0), - first_of_month numeric(10,0), - last_month_id numeric(10,0), - month_end numeric(10,0), - quarter_id numeric(10,0), - quarter_name character varying(200), - quarter_name_cn character varying(200), - quarter_name_short character varying(200), - quarter_name_short_cn character varying(200), - year_id numeric(10,0), - year_name character varying(200), - year_name_cn character varying(200), - description character varying(500), - create_date timestamp without time zone, - month_week_num character varying(100), - month_week_begin character varying(100), - month_week_end character varying(100), - half_year character varying(100), - weekend_flag character varying(100), - holidays_flag character varying(100), - workday_flag character varying(100), - month_number numeric(10,0) -) DISTRIBUTED BY (calendar_id); -ALTER TABLE ONLY dm_calendar ADD CONSTRAINT dm_calendar_pkey PRIMARY KEY (calendar_id); -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "dm_calendar_pkey" for table "dm_calendar" ---TEST -SELECT "year_id" as id , min("year_name") as a from (select "year_id" as "year_id" , min("year_name") as "year_name" from "dm_calendar" group by "year_id") "dm_calendar3" group by "year_id" order by a ASC ; - id | a -----+--- -(0 rows) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS dm_calendar; --- end_ignore ---- ---- Test with/without group by with primary key as dist key ---- --- SETUP --- start_ignore -drop table if exists t; -NOTICE: table "t" does not exist, skipping --- end_ignore -create table t -( - a int NOT NULL, - b int, - c character varying(200), - d numeric(10,0), - e date -) distributed by (b); -alter table t ADD CONSTRAINT pkey primary key (b); -NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "t_pkey" for table "t" --- TEST -SELECT MAX(a) AS m FROM t GROUP BY b ORDER BY m; - m ---- -(0 rows) - --- CLEANUP --- start_ignore -drop table if exists t; --- end_ignore ---- ---- Passing through distribution matching type in default implementation ---- --- SETUP --- start_ignore -drop table if exists customer; -NOTICE: table "customer" does not exist, skipping -drop table if exists sale; -NOTICE: table "sale" does not exist, skipping --- end_ignore -create table customer -( - cn int not null, - cname text not null, - cloc text, - primary key (cn) -) distributed by (cn); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "customer_pkey" for table "customer" -insert into customer values - ( 1, 'Macbeth', 'Inverness'), - ( 2, 'Duncan', 'Forres'), - ( 3, 'Lady Macbeth', 'Inverness'), - ( 4, 'Witches, Inc', 'Lonely Heath'); -create table sale -( - cn int not null, - vn int not null, - pn int not null, - dt date not null, - qty int not null, - prc float not null, - primary key (cn, vn, pn) -) distributed by (cn,vn,pn); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "sale_pkey" for table "sale" -insert into sale values - ( 2, 40, 100, '1401-1-1', 1100, 2400), - ( 1, 10, 200, '1401-3-1', 1, 0), - ( 3, 40, 200, '1401-4-1', 1, 0), - ( 1, 20, 100, '1401-5-1', 1, 0), - ( 1, 30, 300, '1401-5-2', 1, 0), - ( 1, 50, 400, '1401-6-1', 1, 0), - ( 2, 50, 400, '1401-6-1', 1, 0), - ( 1, 30, 500, '1401-6-1', 12, 5), - ( 3, 30, 500, '1401-6-1', 12, 5), - ( 3, 30, 600, '1401-6-1', 12, 5), - ( 4, 40, 700, '1401-6-1', 1, 1), - ( 4, 40, 800, '1401-6-1', 1, 1); - --- TEST -select cname, -rank() over (partition by sale.cn order by vn) -from sale, customer -where sale.cn = customer.cn -order by 1, 2; - cname | rank ---------------+------ - Duncan | 1 - Duncan | 2 - Lady Macbeth | 1 - Lady Macbeth | 1 - Lady Macbeth | 3 - Macbeth | 1 - Macbeth | 2 - Macbeth | 3 - Macbeth | 3 - Macbeth | 5 - Witches, Inc | 1 - Witches, Inc | 1 -(12 rows) - --- CLEANUP --- start_ignore -drop table if exists customer; -drop table if exists sale; --- end_ignore ---- ---- Optimzier query crashing for logical window with no window functions ---- --- SETUP -create table mpp23240(a int, b int, c int, d int, e int, f int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. --- TEST -select a, b, - case 1 - when 10 then - sum(c) over(partition by a) - when 20 then - sum(d) over(partition by a) - else - 5 - end as sum1 -from (select * from mpp23240 where f > 10) x; - a | b | sum1 ----+---+------ -(0 rows) - --- CLEANUP --- start_ignore -drop table mpp23240; --- end_ignore diff --git a/src/test/regress/expected/bfv_partition.out b/src/test/regress/expected/bfv_partition.out deleted file mode 100644 index 79bdd3aff6172c7e1bc8d62f4917405747bc7ab0..0000000000000000000000000000000000000000 --- a/src/test/regress/expected/bfv_partition.out +++ /dev/null @@ -1,1698 +0,0 @@ ---- ---- Initial setup for all the partitioning test for this suite ---- --- start_ignore -drop language if exists plpythonu; -NOTICE: language "plpythonu" does not exist, skipping -create language plpythonu; --- end_ignore -create or replace function count_operator(explain_query text, operator text) returns int as -$$ -rv = plpy.execute(explain_query) -search_text = operator -result = 0 -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = result+1 -return result -$$ -language plpythonu; -create or replace function find_operator(query text, operator_name text) returns text as -$$ -rv = plpy.execute(query) -search_text = operator_name -result = ['false'] -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = ['true'] - break -return result -$$ -language plpythonu; ---- ---- Tests if it produces SIGSEGV from "select from partition_table group by rollup or cube function" ---- --- SETUP --- start_ignore -drop table if exists mpp7980; -NOTICE: table "mpp7980" does not exist, skipping --- end_ignore -create table mpp7980 -( - month_id date, - bill_stmt_id character varying(30), - cust_type character varying(10), - subscription_status character varying(30), - voice_call_min numeric(15,2), - minute_per_call numeric(15,2), - subscription_id character varying(15) -) -distributed by (subscription_id, bill_stmt_id) - PARTITION BY RANGE(month_id) - ( - start ('2009-02-01'::date) end ('2009-08-01'::date) exclusive EVERY (INTERVAL '1 month') - ); -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_1" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_2" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_3" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_4" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_5" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_6" for table "mpp7980" - --- TEST -select count_operator('explain select cust_type, subscription_status,count(distinct subscription_id),sum(voice_call_min),sum(minute_per_call) from mpp7980 where month_id =\'2009-04-01\' group by rollup(1,2);','SIGSEGV'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select cust_type, subscriptio... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -drop table mpp7980; --- end_ignore ---- ---- Tests if it is using casting comparator for partition selector with compatible types ---- --- SETUP -CREATE TABLE TIMESTAMP_MONTH_rangep_STARTINCL (i1 int, f2 timestamp) -partition by range (f2) -( - start ('2000-01-01'::timestamp) INCLUSIVE - end (date '2001-01-01'::timestamp) EXCLUSIVE - every ('1 month'::interval) -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_1" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_2" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_3" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_4" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_5" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_6" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_7" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_8" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_9" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_10" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_11" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_12" for table "timestamp_month_rangep_startincl" -CREATE TABLE TIMESTAMP_MONTH_rangep_STARTEXCL (i1 int, f2 timestamp) -partition by range (f2) -( - start ('2000-01-01'::timestamp) EXCLUSIVE - end (date '2001-01-01'::timestamp) INCLUSIVE - every ('1 month'::interval) -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_1" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_2" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_3" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_4" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_5" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_6" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_7" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_8" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_9" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_10" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_11" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_12" for table "timestamp_month_rangep_startexcl" -CREATE TABLE TIMESTAMP_MONTH_listp (i1 int, f2 timestamp) -partition by list (f2) -( - partition jan1 values ('2000-01-01'::timestamp), - partition jan2 values ('2000-01-02'::timestamp), - partition jan3 values ('2000-01-03'::timestamp), - partition jan4 values ('2000-01-04'::timestamp), - partition jan5 values ('2000-01-05'::timestamp) -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan1" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan2" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan3" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan4" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan5" for table "timestamp_month_listp" --- TEST --- Middle of a middle range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (1, '2000-07-16'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-07-16'; - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - --- Beginning of the first range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (2, '2000-01-01'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-01-01'; - i1 | f2 -----+-------------------------- - 2 | Sat Jan 01 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 2 | Sat Jan 01 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 2 | Sat Jan 01 00:00:00 2000 -(1 row) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (3, '2000-01-02'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-01-02'; - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - --- End of the last range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (4, '2000-12-31'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-12-31'; - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (5, '2001-01-01'); -- should fail, no such partition -ERROR: no partition for partitioning key (seg1 Omers-MacBook-Pro.local:25433 pid=36941) -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2001-01-01'; - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - --- Range partitioning: START EXCLUSIVE, END INCLUSIVE --- Middle of a middle range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (1, '2000-07-16'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-07-16'; - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - --- Beginning of the first range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (2, '2000-01-01'); -- should fail, no such partition -ERROR: no partition for partitioning key (seg0 Omers-MacBook-Pro.local:25432 pid=36940) -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-01-01'; - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (3, '2000-01-02'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-01-02'; - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - --- End of the last range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (4, '2000-12-31'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-12-31'; - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (5, '2001-01-01'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2001-01-01'; - i1 | f2 -----+-------------------------- - 5 | Mon Jan 01 00:00:00 2001 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 5 | Mon Jan 01 00:00:00 2001 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 5 | Mon Jan 01 00:00:00 2001 -(1 row) - --- List partitioning -INSERT INTO TIMESTAMP_MONTH_listp values (1, '2000-01-03'); -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = '2000-01-03'; - i1 | f2 -----+-------------------------- - 1 | Mon Jan 03 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = TO_TIMESTAMP('2000-01-03', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Mon Jan 03 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = TO_DATE('2000-01-03', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Mon Jan 03 00:00:00 2000 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE TIMESTAMP_MONTH_listp; -DROP TABLE TIMESTAMP_MONTH_rangep_STARTEXCL; -DROP TABLE TIMESTAMP_MONTH_rangep_STARTINCL; --- end_ignore ---- ---- Data Engineer can see partition key in psql ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS T26002_T1; -NOTICE: table "t26002_t1" does not exist, skipping -DROP TABLE IF EXISTS T26002_T2; -NOTICE: table "t26002_t2" does not exist, skipping --- end_ignore -CREATE TABLE T26002_T1 (empid int, departmentid int, year int, region varchar(20)) -DISTRIBUTED BY (empid) - PARTITION BY RANGE (year) - SUBPARTITION BY LIST (region, departmentid) - SUBPARTITION TEMPLATE ( - SUBPARTITION usa VALUES (('usa', 1)), - SUBPARTITION europe VALUES (('europe', 2)), - SUBPARTITION asia VALUES (('asia', 3)), - DEFAULT SUBPARTITION other_regions) -( START (2012) END (2015) EVERY (3), - DEFAULT PARTITION outlying_years); -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years" for table "t26002_t1" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2" for table "t26002_t1" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_usa" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_europe" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_asia" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_other_regions" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_usa" for table "t26002_t1_1_prt_2" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_europe" for table "t26002_t1_1_prt_2" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_asia" for table "t26002_t1_1_prt_2" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_other_regions" for table "t26002_t1_1_prt_2" - --- TEST --- expected to see the partition key -\d T26002_T1; - Table "public.t26002_t1" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Number of child tables: 2 (Use \d+ to list them.) -Distributed by: (empid) -Partition by: (year) - -\d t26002_t1_1_prt_2; - Table "public.t26002_t1_1_prt_2" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Check constraints: - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1 -Number of child tables: 4 (Use \d+ to list them.) -Distributed by: (empid) -Partition by: (region, departmentid) - -\d t26002_t1_1_prt_2_2_prt_asia; - Table "public.t26002_t1_1_prt_2_2_prt_asia" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Check constraints: - "t26002_t1_1_prt_2_2_prt_asia_check" CHECK (region::text = 'asia'::text AND departmentid = 3) - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1_1_prt_2 -Distributed by: (empid) - -\d+ T26002_T1; - Table "public.t26002_t1" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Child tables: t26002_t1_1_prt_2, - t26002_t1_1_prt_outlying_years -Has OIDs: no -Distributed by: (empid) -Partition by: (year) - -\d+ t26002_t1_1_prt_2; - Table "public.t26002_t1_1_prt_2" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Check constraints: - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1 -Child tables: t26002_t1_1_prt_2_2_prt_asia, - t26002_t1_1_prt_2_2_prt_europe, - t26002_t1_1_prt_2_2_prt_other_regions, - t26002_t1_1_prt_2_2_prt_usa -Has OIDs: no -Distributed by: (empid) -Partition by: (region, departmentid) - -\d+ t26002_t1_1_prt_2_2_prt_asia; - Table "public.t26002_t1_1_prt_2_2_prt_asia" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Check constraints: - "t26002_t1_1_prt_2_2_prt_asia_check" CHECK (region::text = 'asia'::text AND departmentid = 3) - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1_1_prt_2 -Has OIDs: no -Distributed by: (empid) - -/* --- test 2: Data Engineer won't see partition key for non-partitioned table -GIVEN I am a Data Engineer -WHEN I run \d on a non-partitioned table -THEN I should NOT see the partition key in the output -*/ -CREATE TABLE T26002_T2 (empid int, departmentid int, year int, region varchar(20)) -DISTRIBUTED BY (empid); -\d T26002_T2; - Table "public.t26002_t2" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Distributed by: (empid) - -\d+ T26002_T2; - Table "public.t26002_t2" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Has OIDs: no -Distributed by: (empid) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS T26002_T1; -DROP TABLE IF EXISTS T26002_T2; --- end_ignore --- ************ORCA ENABLED********** --- --- MPP-23195 --- --- SETUP --- start_ignore -set optimizer_enable_bitmapscan=on; -set optimizer_enable_indexjoin=on; -drop table if exists mpp23195_t1; -NOTICE: table "mpp23195_t1" does not exist, skipping -drop table if exists mpp23195_t2; -NOTICE: table "mpp23195_t2" does not exist, skipping --- end_ignore -create table mpp23195_t1 (i int) partition by range(i) (partition pt1 start(1) end(10), partition pt2 start(10) end(20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "mpp23195_t1_1_prt_pt1" for table "mpp23195_t1" -NOTICE: CREATE TABLE will create partition "mpp23195_t1_1_prt_pt2" for table "mpp23195_t1" -create index index_mpp23195_t1_i on mpp23195_t1(i); -NOTICE: building index for child partition "mpp23195_t1_1_prt_pt1" -NOTICE: building index for child partition "mpp23195_t1_1_prt_pt2" -create table mpp23195_t2(i int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -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 mpp23195_t1 values (generate_series(1,19)); -insert into mpp23195_t2 values (1); --- TEST -select find_operator('explain select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;', 'Dynamic Index Scan'); - find_operator ---------------- - ['false'] -(1 row) - -select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i; - i | i ----+--- -(0 rows) - --- CLEANUP --- start_ignore -drop table if exists mpp23195_t1; -drop table if exists mpp23195_t2; -set optimizer_enable_bitmapscan=off; -set optimizer_enable_indexjoin=off; --- end_ignore ---- ---- Check we have Dynamic Index Scan operator and check we have Nest loop operator ---- --- SETUP --- start_ignore -drop table if exists mpp21834_t1; -NOTICE: table "mpp21834_t1" does not exist, skipping -drop table if exists mpp21834_t2; -NOTICE: table "mpp21834_t2" does not exist, skipping --- end_ignore -create table mpp21834_t1 (i int, j int) partition by range(i) (partition pp1 start(1) end(10), partition pp2 start(10) end(20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "mpp21834_t1_1_prt_pp1" for table "mpp21834_t1" -NOTICE: CREATE TABLE will create partition "mpp21834_t1_1_prt_pp2" for table "mpp21834_t1" -create index index_1 on mpp21834_t1(i); -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp1" -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp2" -create index index_2 on mpp21834_t1(j); -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp1" -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp2" -create table mpp21834_t2(i int, j int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. --- TEST --- start_ignore -select disable_xform('CXformInnerJoin2HashJoin'); - disable_xform --------------------------------------- - CXformInnerJoin2HashJoin is disabled -(1 row) - --- end_ignore -select find_operator('explain analyze select * from mpp21834_t2,mpp21834_t1 where mpp21834_t2.i < mpp21834_t1.i;','Dynamic Index Scan'); - find_operator ---------------- - ['false'] -(1 row) - -select find_operator('explain analyze select * from mpp21834_t2,mpp21834_t1 where mpp21834_t2.i < mpp21834_t1.i;','Nested Loop'); - find_operator ---------------- - ['true'] -(1 row) - --- CLEANUP --- start_ignore -drop index index_2; -WARNING: Only dropped the index "index_2" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop index index_1; -WARNING: Only dropped the index "index_1" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists mpp21834_t2; -drop table if exists mpp21834_t1; -select enable_xform('CXformInnerJoin2HashJoin'); - enable_xform -------------------------------------- - CXformInnerJoin2HashJoin is enabled -(1 row) - --- end_ignore ---- ---- A rescanning of DTS with its own partition selector (under sequence node) ---- --- SETUP --- start_ignore -set optimizer_enable_broadcast_nestloop_outer_child=on; -drop table if exists mpp23288; -NOTICE: table "mpp23288" does not exist, skipping --- end_ignore -create table mpp23288(a int, b int) - partition by range (a) - ( - PARTITION pfirst END(5) INCLUSIVE, - PARTITION pinter START(5) EXCLUSIVE END (10) INCLUSIVE, - PARTITION plast START (10) EXCLUSIVE - ); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "mpp23288_1_prt_pfirst" for table "mpp23288" -NOTICE: CREATE TABLE will create partition "mpp23288_1_prt_pinter" for table "mpp23288" -NOTICE: CREATE TABLE will create partition "mpp23288_1_prt_plast" for table "mpp23288" -insert into mpp23288(a) select generate_series(1,20); -analyze mpp23288; --- TEST -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and t2.a =10) order by t2.a, t1.a;','Dynamic Table Scan'); - count_operator ----------------- - 0 -(1 row) - -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and t2.a =10) order by t2.a, t1.a; - a | a -----+--- - 10 | 1 - 10 | 2 - 10 | 3 - 10 | 4 - 10 | 5 - 10 | 6 - 10 | 7 - 10 | 8 - 10 | 9 -(9 rows) - -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and (t2.a = 10 or t2.a = 5 or t2.a = 12)) order by t2.a, t1.a;','Dynamic Table Scan'); - count_operator ----------------- - 0 -(1 row) - -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and (t2.a = 10 or t2.a = 5 or t2.a = 12)) order by t2.a, t1.a; - a | a -----+---- - 5 | 1 - 5 | 2 - 5 | 3 - 5 | 4 - 10 | 1 - 10 | 2 - 10 | 3 - 10 | 4 - 10 | 5 - 10 | 6 - 10 | 7 - 10 | 8 - 10 | 9 - 12 | 1 - 12 | 2 - 12 | 3 - 12 | 4 - 12 | 5 - 12 | 6 - 12 | 7 - 12 | 8 - 12 | 9 - 12 | 10 - 12 | 11 -(24 rows) - -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on t1.a < t2.a and t2.a = 1 or t2.a < 10 order by t2.a, t1.a;','Dynamic Table Scan'); - count_operator ----------------- - 0 -(1 row) - -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on t1.a < t2.a and t2.a = 1 or t2.a < 10 order by t2.a, t1.a; - a | a ----+---- - 1 | 1 - 1 | 2 - 1 | 3 - 1 | 4 - 1 | 5 - 1 | 6 - 1 | 7 - 1 | 8 - 1 | 9 - 1 | 10 - 1 | 11 - 1 | 12 - 1 | 13 - 1 | 14 - 1 | 15 - 1 | 16 - 1 | 17 - 1 | 18 - 1 | 19 - 1 | 20 - 2 | 1 - 2 | 2 - 2 | 3 - 2 | 4 - 2 | 5 - 2 | 6 - 2 | 7 - 2 | 8 - 2 | 9 - 2 | 10 - 2 | 11 - 2 | 12 - 2 | 13 - 2 | 14 - 2 | 15 - 2 | 16 - 2 | 17 - 2 | 18 - 2 | 19 - 2 | 20 - 3 | 1 - 3 | 2 - 3 | 3 - 3 | 4 - 3 | 5 - 3 | 6 - 3 | 7 - 3 | 8 - 3 | 9 - 3 | 10 - 3 | 11 - 3 | 12 - 3 | 13 - 3 | 14 - 3 | 15 - 3 | 16 - 3 | 17 - 3 | 18 - 3 | 19 - 3 | 20 - 4 | 1 - 4 | 2 - 4 | 3 - 4 | 4 - 4 | 5 - 4 | 6 - 4 | 7 - 4 | 8 - 4 | 9 - 4 | 10 - 4 | 11 - 4 | 12 - 4 | 13 - 4 | 14 - 4 | 15 - 4 | 16 - 4 | 17 - 4 | 18 - 4 | 19 - 4 | 20 - 5 | 1 - 5 | 2 - 5 | 3 - 5 | 4 - 5 | 5 - 5 | 6 - 5 | 7 - 5 | 8 - 5 | 9 - 5 | 10 - 5 | 11 - 5 | 12 - 5 | 13 - 5 | 14 - 5 | 15 - 5 | 16 - 5 | 17 - 5 | 18 - 5 | 19 - 5 | 20 - 6 | 1 - 6 | 2 - 6 | 3 - 6 | 4 - 6 | 5 - 6 | 6 - 6 | 7 - 6 | 8 - 6 | 9 - 6 | 10 - 6 | 11 - 6 | 12 - 6 | 13 - 6 | 14 - 6 | 15 - 6 | 16 - 6 | 17 - 6 | 18 - 6 | 19 - 6 | 20 - 7 | 1 - 7 | 2 - 7 | 3 - 7 | 4 - 7 | 5 - 7 | 6 - 7 | 7 - 7 | 8 - 7 | 9 - 7 | 10 - 7 | 11 - 7 | 12 - 7 | 13 - 7 | 14 - 7 | 15 - 7 | 16 - 7 | 17 - 7 | 18 - 7 | 19 - 7 | 20 - 8 | 1 - 8 | 2 - 8 | 3 - 8 | 4 - 8 | 5 - 8 | 6 - 8 | 7 - 8 | 8 - 8 | 9 - 8 | 10 - 8 | 11 - 8 | 12 - 8 | 13 - 8 | 14 - 8 | 15 - 8 | 16 - 8 | 17 - 8 | 18 - 8 | 19 - 8 | 20 - 9 | 1 - 9 | 2 - 9 | 3 - 9 | 4 - 9 | 5 - 9 | 6 - 9 | 7 - 9 | 8 - 9 | 9 - 9 | 10 - 9 | 11 - 9 | 12 - 9 | 13 - 9 | 14 - 9 | 15 - 9 | 16 - 9 | 17 - 9 | 18 - 9 | 19 - 9 | 20 -(180 rows) - --- CLEANUP --- start_ignore -drop table if exists mpp23288; -set optimizer_enable_broadcast_nestloop_outer_child=off; --- end_ignore ---- ---- Testing whether test gives wrong results with partition tables when sub-partitions are distributed differently than the parent partition. ---- --- SETUP --- start_ignore -drop table if exists pt; -NOTICE: table "pt" does not exist, skipping -drop table if exists t; -NOTICE: table "t" does not exist, skipping --- end_ignore -create table pt(a int, b int, c int) distributed by (a) partition by range(b) (start(0) end(10) every (2)); -NOTICE: CREATE TABLE will create partition "pt_1_prt_1" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_2" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_3" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_4" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_5" for table "pt" -alter table pt_1_prt_1 set distributed randomly; -create table t(a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -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 pt select g%10, g%2 + 1, g*2 from generate_series(1,20) g; -insert into pt values(1,1,3); -insert into t select g%10, g%2 + 1 from generate_series(1,20) g; -create index pt_c on pt(c); -NOTICE: building index for child partition "pt_1_prt_1" -NOTICE: building index for child partition "pt_1_prt_2" -NOTICE: building index for child partition "pt_1_prt_3" -NOTICE: building index for child partition "pt_1_prt_4" -NOTICE: building index for child partition "pt_1_prt_5" -analyze t; -analyze pt; --- TEST -SELECT COUNT(*) FROM pt, t WHERE pt.a = t.a; - count -------- - 42 -(1 row) - -SELECT COUNT(*) FROM pt, t WHERE pt.a = t.a and pt.c=4; - count -------- - 2 -(1 row) - -select a, count(*) from pt group by a; - a | count ----+------- - 2 | 2 - 1 | 3 - 0 | 2 - 9 | 2 - 8 | 2 - 3 | 2 - 6 | 2 - 7 | 2 - 5 | 2 - 4 | 2 -(10 rows) - -select b, count(*) from pt group by b; - b | count ----+------- - 2 | 10 - 1 | 11 -(2 rows) - -select a, count(*) from pt where a<2 group by a; - a | count ----+------- - 1 | 3 - 0 | 2 -(2 rows) - --- CLEANUP --- start_ignore -drop index pt_c; -WARNING: Only dropped the index "pt_c" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists pt; -drop table if exists t; --- end_ignore ---- ---- Tests if DynamicIndexScan sets tuple descriptor of the planstate->ps_ResultTupleSlot ---- --- SETUP --- start_ignore -drop table if exists mpp24151_t; -NOTICE: table "mpp24151_t" does not exist, skipping -drop table if exists mpp24151_pt; -NOTICE: table "mpp24151_pt" does not exist, skipping --- end_ignore -create table mpp24151_t(dist int, tid int, t1 text, t2 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'dist' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create table mpp24151_pt(dist int, pt1 text, pt2 text, pt3 text, ptid int) -DISTRIBUTED BY (dist) -PARTITION BY RANGE(ptid) - ( - START (0) END (5) EVERY (1), - DEFAULT PARTITION junk_data - ) -; -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_junk_data" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_2" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_3" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_4" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_5" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_6" for table "mpp24151_pt" -create index pt1_idx on mpp24151_pt using btree (pt1); -NOTICE: building index for child partition "mpp24151_pt_1_prt_junk_data" -NOTICE: building index for child partition "mpp24151_pt_1_prt_2" -NOTICE: building index for child partition "mpp24151_pt_1_prt_3" -NOTICE: building index for child partition "mpp24151_pt_1_prt_4" -NOTICE: building index for child partition "mpp24151_pt_1_prt_5" -NOTICE: building index for child partition "mpp24151_pt_1_prt_6" -create index ptid_idx on mpp24151_pt using btree (ptid); -NOTICE: building index for child partition "mpp24151_pt_1_prt_junk_data" -NOTICE: building index for child partition "mpp24151_pt_1_prt_2" -NOTICE: building index for child partition "mpp24151_pt_1_prt_3" -NOTICE: building index for child partition "mpp24151_pt_1_prt_4" -NOTICE: building index for child partition "mpp24151_pt_1_prt_5" -NOTICE: building index for child partition "mpp24151_pt_1_prt_6" -insert into mpp24151_pt select i, 'hello' || 0, 'world', 'drop this', i % 6 from generate_series(0,100)i; -insert into mpp24151_pt select i, 'hello' || i, 'world', 'drop this', i % 6 from generate_series(0,200000)i; -insert into mpp24151_t select i, i % 6, 'hello' || i, 'bar' from generate_series(0,10)i; -analyze mpp24151_pt; -analyze mpp24151_t; --- TEST --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan'); - disable_xform ------------------------------------------------ - CXformDynamicGet2DynamicTableScan is disabled -(1 row) - --- end_ignore -select count_operator('explain select * from mpp24151_t, mpp24151_pt where tid = ptid and pt1 = \'hello0\';','Result'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from mpp24151_t, mpp... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 6 -(1 row) - -select * from mpp24151_t, mpp24151_pt where tid = ptid and pt1 = 'hello0'; - dist | tid | t1 | t2 | dist | pt1 | pt2 | pt3 | ptid -------+-----+---------+-----+------+--------+-------+-----------+------ - 5 | 5 | hello5 | bar | 11 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 23 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 47 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 59 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 65 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 95 | hello0 | world | drop this | 5 - 0 | 0 | hello0 | bar | 12 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 12 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 24 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 24 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 60 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 60 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 66 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 66 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 78 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 78 | hello0 | world | drop this | 0 - 1 | 1 | hello1 | bar | 25 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 25 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 43 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 43 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 61 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 61 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 67 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 67 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 79 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 79 | hello0 | world | drop this | 1 - 2 | 2 | hello2 | bar | 8 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 8 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 26 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 26 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 32 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 32 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 44 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 44 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 62 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 62 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 80 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 80 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 92 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 92 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 98 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 98 | hello0 | world | drop this | 2 - 9 | 3 | hello9 | bar | 9 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 9 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 27 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 27 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 45 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 45 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 81 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 81 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 93 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 93 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 99 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 99 | hello0 | world | drop this | 3 - 10 | 4 | hello10 | bar | 100 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 100 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 94 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 94 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 82 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 82 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 64 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 64 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 58 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 58 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 46 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 46 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 10 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 10 | hello0 | world | drop this | 4 - 5 | 5 | hello5 | bar | 17 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 29 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 35 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 71 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 83 | hello0 | world | drop this | 5 - 6 | 0 | hello6 | bar | 0 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 0 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 30 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 30 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 36 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 36 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 48 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 48 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 72 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 72 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 84 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 84 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 0 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 0 | hello0 | world | drop this | 0 - 7 | 1 | hello7 | bar | 1 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 1 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 13 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 13 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 31 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 31 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 37 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 37 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 49 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 49 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 85 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 85 | hello0 | world | drop this | 1 - 2 | 2 | hello2 | bar | 2 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 2 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 14 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 14 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 50 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 50 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 68 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 68 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 86 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 86 | hello0 | world | drop this | 2 - 3 | 3 | hello3 | bar | 15 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 15 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 33 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 33 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 51 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 51 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 63 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 63 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 69 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 69 | hello0 | world | drop this | 3 - 4 | 4 | hello4 | bar | 70 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 70 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 52 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 52 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 34 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 34 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 28 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 28 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 16 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 16 | hello0 | world | drop this | 4 - 5 | 5 | hello5 | bar | 5 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 41 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 53 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 77 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 89 | hello0 | world | drop this | 5 - 0 | 0 | hello0 | bar | 6 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 6 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 18 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 18 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 42 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 42 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 54 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 54 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 90 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 90 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 96 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 96 | hello0 | world | drop this | 0 - 1 | 1 | hello1 | bar | 7 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 7 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 19 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 19 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 55 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 55 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 73 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 73 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 91 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 91 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 97 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 97 | hello0 | world | drop this | 1 - 2 | 2 | hello2 | bar | 20 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 20 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 38 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 38 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 56 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 56 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 74 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 74 | hello0 | world | drop this | 2 - 9 | 3 | hello9 | bar | 3 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 3 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 21 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 21 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 39 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 39 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 57 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 57 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 75 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 75 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 87 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 87 | hello0 | world | drop this | 3 - 10 | 4 | hello10 | bar | 88 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 88 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 76 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 76 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 40 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 40 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 22 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 22 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 4 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 4 | hello0 | world | drop this | 4 -(188 rows) - --- CLEANUP --- start_ignore -drop index ptid_idx; -WARNING: Only dropped the index "ptid_idx" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop index pt1_idx; -WARNING: Only dropped the index "pt1_idx" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists mpp24151_t; -drop table if exists mpp24151_pt; -select enable_xform('CXformDynamicGet2DynamicTableScan'); - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - --- end_ignore ---- ---- No DPE (Dynamic Partition Elimination) on second child of a union under a join ---- --- SETUP --- start_ignore -drop table if exists t; -NOTICE: table "t" does not exist, skipping -drop table if exists p1; -NOTICE: table "p1" does not exist, skipping -drop table if exists p2; -NOTICE: table "p2" does not exist, skipping -drop table if exists p3; -NOTICE: table "p3" does not exist, skipping -drop table if exists p; -NOTICE: table "p" does not exist, skipping --- end_ignore -create table p1 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "p1_1_prt_1" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_2" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_3" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_4" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_5" for table "p1" -create table p2 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "p2_1_prt_1" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_2" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_3" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_4" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_5" for table "p2" -create table p3 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "p3_1_prt_1" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_2" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_3" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_4" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_5" for table "p3" -create table p (a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create table t(a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -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 select g, g*10 from generate_series(1,100) g; -insert into p1 select g, g%99 +1 from generate_series(1,10000) g; -insert into p2 select g, g%99 +1 from generate_series(1,10000) g; -insert into p3 select g, g%99 +1 from generate_series(1,10000) g; -insert into p select g, g%99 +1 from generate_series(1,10000) g; -analyze t; -analyze p1; -analyze p2; -analyze p3; -analyze p; --- TEST -select count_operator('explain select * from (select * from p1 union all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 except all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 except select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 intersect all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2 union all select * from p3) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2 union all select * from p) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p union all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2 intersect all select * from p3) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p intersect all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -drop table t; -drop table p1; -drop table p2; -drop table p3; -drop table p; --- end_ignore ---- ---- Gracefully handle NULL partition set from BitmapTableScan, DynamicTableScan and DynamicIndexScan ---- --- SETUP --- start_ignore -drop table if exists dts; -NOTICE: table "dts" does not exist, skipping -drop table if exists dis; -NOTICE: table "dis" does not exist, skipping -drop table if exists dbs; -NOTICE: table "dbs" does not exist, skipping --- end_ignore -create table dts(c1 int, c2 int) partition by range(c2) (start(1) end(11) every(1)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "dts_1_prt_1" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_2" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_3" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_4" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_5" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_6" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_7" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_8" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_9" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_10" for table "dts" -create table dis(c1 int, c2 int, c3 int) partition by range(c2) (start(1) end(11) every(1)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "dis_1_prt_1" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_2" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_3" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_4" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_5" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_6" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_7" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_8" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_9" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_10" for table "dis" -create index dis_index on dis(c3); -NOTICE: building index for child partition "dis_1_prt_1" -NOTICE: building index for child partition "dis_1_prt_2" -NOTICE: building index for child partition "dis_1_prt_3" -NOTICE: building index for child partition "dis_1_prt_4" -NOTICE: building index for child partition "dis_1_prt_5" -NOTICE: building index for child partition "dis_1_prt_6" -NOTICE: building index for child partition "dis_1_prt_7" -NOTICE: building index for child partition "dis_1_prt_8" -NOTICE: building index for child partition "dis_1_prt_9" -NOTICE: building index for child partition "dis_1_prt_10" -CREATE TABLE dbs(c1 int, c2 int, c3 int) partition by range(c2) (start(1) end(11) every(1)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "dbs_1_prt_1" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_2" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_3" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_4" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_5" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_6" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_7" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_8" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_9" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_10" for table "dbs" -create index dbs_index on dbs using bitmap(c3); -NOTICE: building index for child partition "dbs_1_prt_1" -NOTICE: building index for child partition "dbs_1_prt_2" -NOTICE: building index for child partition "dbs_1_prt_3" -NOTICE: building index for child partition "dbs_1_prt_4" -NOTICE: building index for child partition "dbs_1_prt_5" -NOTICE: building index for child partition "dbs_1_prt_6" -NOTICE: building index for child partition "dbs_1_prt_7" -NOTICE: building index for child partition "dbs_1_prt_8" -NOTICE: building index for child partition "dbs_1_prt_9" -NOTICE: building index for child partition "dbs_1_prt_10" --- TEST -select find_operator('explain (select * from dts where c2 = 1) union (select * from dts where c2 = 2) union (select * from dts where c2 = 3) union (select * from dts where c2 = 4) union (select * from dts where c2 = 5) union (select * from dts where c2 = 6) union (select * from dts where c2 = 7) union (select * from dts where c2 = 8) union (select * from dts where c2 = 9) union (select * from dts where c2 = 10);', 'Dynamic Table Scan'); - find_operator ---------------- - ['false'] -(1 row) - -(select * from dts where c2 = 1) union -(select * from dts where c2 = 2) union -(select * from dts where c2 = 3) union -(select * from dts where c2 = 4) union -(select * from dts where c2 = 5) union -(select * from dts where c2 = 6) union -(select * from dts where c2 = 7) union -(select * from dts where c2 = 8) union -(select * from dts where c2 = 9) union -(select * from dts where c2 = 10); - c1 | c2 -----+---- -(0 rows) - --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan'); - disable_xform ------------------------------------------------ - CXformDynamicGet2DynamicTableScan is disabled -(1 row) - --- end_ignore -select find_operator('explain (select * from dis where c3 = 1) union (select * from dis where c3 = 2) union (select * from dis where c3 = 3) union (select * from dis where c3 = 4) union (select * from dis where c3 = 5) union (select * from dis where c3 = 6) union (select * from dis where c3 = 7) union (select * from dis where c3 = 8) union (select * from dis where c3 = 9) union (select * from dis where c3 = 10);', 'Dynamic Index Scan'); - find_operator ---------------- - ['false'] -(1 row) - -(select * from dis where c3 = 1) union -(select * from dis where c3 = 2) union -(select * from dis where c3 = 3) union -(select * from dis where c3 = 4) union -(select * from dis where c3 = 5) union -(select * from dis where c3 = 6) union -(select * from dis where c3 = 7) union -(select * from dis where c3 = 8) union -(select * from dis where c3 = 9) union -(select * from dis where c3 = 10); - c1 | c2 | c3 -----+----+---- -(0 rows) - -select find_operator('explain select * from dbs where c2= 15 and c3 = 5;', 'Bitmap Table Scan'); - find_operator ---------------- - ['false'] -(1 row) - -select * from dbs where c2= 15 and c3 = 5; - c1 | c2 | c3 -----+----+---- -(0 rows) - --- CLEANUP --- start_ignore -drop index dbs_index; -WARNING: Only dropped the index "dbs_index" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists dbs; -drop index dis_index; -WARNING: Only dropped the index "dis_index" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists dis; -drop table if exists dts; -select enable_xform('CXformDynamicGet2DynamicTableScan'); - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - --- end_ignore ---- ---- Partition elimination for heterogenous DynamicIndexScans ---- --- SETUP --- start_ignore -drop table if exists pp; -NOTICE: table "pp" does not exist, skipping -drop index if exists pp_1_prt_1_idx; -NOTICE: index "pp_1_prt_1_idx" does not exist, skipping -drop index if exists pp_rest_1_idx; -NOTICE: index "pp_rest_1_idx" does not exist, skipping -drop index if exists pp_rest_2_idx; -NOTICE: index "pp_rest_2_idx" does not exist, skipping -set optimizer_segments=2; -set optimizer_partition_selection_log=on; --- end_ignore -create table pp(a int, b int, c int) partition by range(b) (start(1) end(15) every(5)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "pp_1_prt_1" for table "pp" -NOTICE: CREATE TABLE will create partition "pp_1_prt_2" for table "pp" -NOTICE: CREATE TABLE will create partition "pp_1_prt_3" for table "pp" -insert into pp values (1,1,2),(2,6,2), (3,11,2); --- Heterogeneous Index on the partition table -create index pp_1_prt_1_idx on pp_1_prt_1(c); --- Create other indexes so that we can automate the repro for MPP-21069 by disabling tablescan -create index pp_rest_1_idx on pp_1_prt_2(c,a); -create index pp_rest_2_idx on pp_1_prt_3(c,a); --- TEST --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan') ; - disable_xform ------------------------------------------------ - CXformDynamicGet2DynamicTableScan is disabled -(1 row) - --- end_ignore -select * from pp where b=2 and c=2; - a | b | c ----+---+--- -(0 rows) - -select count_operator('explain select * from pp where b=2 and c=2;','Partition Selector'); - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -drop index if exists pp_rest_2_idx; -drop index if exists pp_rest_1_idx; -drop index if exists pp_1_prt_1_idx; -drop table if exists pp; -select enable_xform('CXformDynamicGet2DynamicTableScan') ; - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - -reset optimizer_segments; -set optimizer_partition_selection_log=off; -select enable_xform('CXformDynamicGet2DynamicTableScan') ; - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - --- end_ignore ---- ---- Partition elimination with implicit CAST on the partitioning key ---- --- SETUP --- start_ignore -set optimizer_segments=2; -set optimizer_partition_selection_log=on; -DROP TABLE IF EXISTS ds_4; -NOTICE: table "ds_4" does not exist, skipping --- end_ignore -CREATE TABLE ds_4 -( - month_id character varying(6), - cust_group_acc numeric(10), - mobile_no character varying(10) -) -DISTRIBUTED BY (cust_group_acc, mobile_no) -PARTITION BY LIST(month_id) - ( - PARTITION p200800 VALUES('200800'), - PARTITION p200801 VALUES('200801'), - PARTITION p200802 VALUES('200802'), - PARTITION p200803 VALUES('200803') -); -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200800" for table "ds_4" -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200801" for table "ds_4" -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200802" for table "ds_4" -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200803" for table "ds_4" --- TEST -select * from ds_4 where month_id = '200800'; - month_id | cust_group_acc | mobile_no -----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 where month_id = \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 where mont... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - -select * from ds_4 where month_id > '200800'; - month_id | cust_group_acc | mobile_no -----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 where month_id > \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 where mont... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - -select * from ds_4 where month_id <= '200800'; - month_id | cust_group_acc | mobile_no -----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 where month_id <= \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 where mont... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - -select * from ds_4 a1,ds_4 a2 where a1.month_id = a2.month_id and a1.month_id > '200800'; - month_id | cust_group_acc | mobile_no | month_id | cust_group_acc | mobile_no -----------+----------------+-----------+----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 a1,ds_4 a2 where a1.month_id = a2.month_id and a1.month_id > \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 a1,ds_4 a2... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS ds_4; -set optimizer_partition_selection_log=off; -reset optimizer_segments; -drop function if exists find_operator(query text, operator_name text); -drop function if exists count_operator(query text, operator_name text); -drop language if exists plpythonu; --- end_ignore diff --git a/src/test/regress/expected/bfv_partition_optimizer.out b/src/test/regress/expected/bfv_partition_optimizer.out deleted file mode 100644 index 4c9010bdfcb7a52f96402837e9d015c768f13758..0000000000000000000000000000000000000000 --- a/src/test/regress/expected/bfv_partition_optimizer.out +++ /dev/null @@ -1,1701 +0,0 @@ ---- ---- Initial setup for all the partitioning test for this suite ---- --- start_ignore -drop language if exists plpythonu; -NOTICE: language "plpythonu" does not exist, skipping -create language plpythonu; --- end_ignore -create or replace function count_operator(explain_query text, operator text) returns int as -$$ -rv = plpy.execute(explain_query) -search_text = operator -result = 0 -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = result+1 -return result -$$ -language plpythonu; -create or replace function find_operator(query text, operator_name text) returns text as -$$ -rv = plpy.execute(query) -search_text = operator_name -result = ['false'] -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = ['true'] - break -return result -$$ -language plpythonu; ---- ---- Tests if it produces SIGSEGV from "select from partition_table group by rollup or cube function" ---- --- SETUP --- start_ignore -drop table if exists mpp7980; -NOTICE: table "mpp7980" does not exist, skipping --- end_ignore -create table mpp7980 -( - month_id date, - bill_stmt_id character varying(30), - cust_type character varying(10), - subscription_status character varying(30), - voice_call_min numeric(15,2), - minute_per_call numeric(15,2), - subscription_id character varying(15) -) -distributed by (subscription_id, bill_stmt_id) - PARTITION BY RANGE(month_id) - ( - start ('2009-02-01'::date) end ('2009-08-01'::date) exclusive EVERY (INTERVAL '1 month') - ); -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_1" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_2" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_3" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_4" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_5" for table "mpp7980" -NOTICE: CREATE TABLE will create partition "mpp7980_1_prt_6" for table "mpp7980" - --- TEST -select count_operator('explain select cust_type, subscription_status,count(distinct subscription_id),sum(voice_call_min),sum(minute_per_call) from mpp7980 where month_id =\'2009-04-01\' group by rollup(1,2);','SIGSEGV'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select cust_type, subscriptio... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - --- CLEANUP --- start_ignore -drop table mpp7980; --- end_ignore ---- ---- Tests if it is using casting comparator for partition selector with compatible types ---- --- SETUP -CREATE TABLE TIMESTAMP_MONTH_rangep_STARTINCL (i1 int, f2 timestamp) -partition by range (f2) -( - start ('2000-01-01'::timestamp) INCLUSIVE - end (date '2001-01-01'::timestamp) EXCLUSIVE - every ('1 month'::interval) -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_1" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_2" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_3" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_4" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_5" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_6" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_7" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_8" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_9" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_10" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_11" for table "timestamp_month_rangep_startincl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startincl_1_prt_12" for table "timestamp_month_rangep_startincl" -CREATE TABLE TIMESTAMP_MONTH_rangep_STARTEXCL (i1 int, f2 timestamp) -partition by range (f2) -( - start ('2000-01-01'::timestamp) EXCLUSIVE - end (date '2001-01-01'::timestamp) INCLUSIVE - every ('1 month'::interval) -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_1" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_2" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_3" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_4" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_5" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_6" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_7" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_8" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_9" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_10" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_11" for table "timestamp_month_rangep_startexcl" -NOTICE: CREATE TABLE will create partition "timestamp_month_rangep_startexcl_1_prt_12" for table "timestamp_month_rangep_startexcl" -CREATE TABLE TIMESTAMP_MONTH_listp (i1 int, f2 timestamp) -partition by list (f2) -( - partition jan1 values ('2000-01-01'::timestamp), - partition jan2 values ('2000-01-02'::timestamp), - partition jan3 values ('2000-01-03'::timestamp), - partition jan4 values ('2000-01-04'::timestamp), - partition jan5 values ('2000-01-05'::timestamp) -); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan1" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan2" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan3" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan4" for table "timestamp_month_listp" -NOTICE: CREATE TABLE will create partition "timestamp_month_listp_1_prt_jan5" for table "timestamp_month_listp" --- TEST --- Middle of a middle range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (1, '2000-07-16'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-07-16'; - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - --- Beginning of the first range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (2, '2000-01-01'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-01-01'; - i1 | f2 -----+-------------------------- - 2 | Sat Jan 01 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 2 | Sat Jan 01 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 2 | Sat Jan 01 00:00:00 2000 -(1 row) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (3, '2000-01-02'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-01-02'; - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - --- End of the last range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (4, '2000-12-31'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-12-31'; - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (5, '2001-01-01'); -- should fail, no such partition -ERROR: no partition for partitioning key (seg1 Omers-MacBook-Pro.local:25433 pid=35739) -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2001-01-01'; - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - --- Range partitioning: START EXCLUSIVE, END INCLUSIVE --- Middle of a middle range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (1, '2000-07-16'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-07-16'; - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-07-16', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Sun Jul 16 00:00:00 2000 -(1 row) - --- Beginning of the first range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (2, '2000-01-01'); -- should fail, no such partition -ERROR: no partition for partitioning key (seg0 Omers-MacBook-Pro.local:25432 pid=35738) -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-01-01'; - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+---- -(0 rows) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (3, '2000-01-02'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-01-02'; - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-01-02', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 3 | Sun Jan 02 00:00:00 2000 -(1 row) - --- End of the last range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (4, '2000-12-31'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-12-31'; - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-12-31', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 4 | Sun Dec 31 00:00:00 2000 -(1 row) - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (5, '2001-01-01'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2001-01-01'; - i1 | f2 -----+-------------------------- - 5 | Mon Jan 01 00:00:00 2001 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 5 | Mon Jan 01 00:00:00 2001 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2001-01-01', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 5 | Mon Jan 01 00:00:00 2001 -(1 row) - --- List partitioning -INSERT INTO TIMESTAMP_MONTH_listp values (1, '2000-01-03'); -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = '2000-01-03'; - i1 | f2 -----+-------------------------- - 1 | Mon Jan 03 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = TO_TIMESTAMP('2000-01-03', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Mon Jan 03 00:00:00 2000 -(1 row) - -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = TO_DATE('2000-01-03', 'YYYY-MM-DD'); - i1 | f2 -----+-------------------------- - 1 | Mon Jan 03 00:00:00 2000 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE TIMESTAMP_MONTH_listp; -DROP TABLE TIMESTAMP_MONTH_rangep_STARTEXCL; -DROP TABLE TIMESTAMP_MONTH_rangep_STARTINCL; --- end_ignore ---- ---- Data Engineer can see partition key in psql ---- --- SETUP --- start_ignore -DROP TABLE IF EXISTS T26002_T1; -NOTICE: table "t26002_t1" does not exist, skipping -DROP TABLE IF EXISTS T26002_T2; -NOTICE: table "t26002_t2" does not exist, skipping --- end_ignore -CREATE TABLE T26002_T1 (empid int, departmentid int, year int, region varchar(20)) -DISTRIBUTED BY (empid) - PARTITION BY RANGE (year) - SUBPARTITION BY LIST (region, departmentid) - SUBPARTITION TEMPLATE ( - SUBPARTITION usa VALUES (('usa', 1)), - SUBPARTITION europe VALUES (('europe', 2)), - SUBPARTITION asia VALUES (('asia', 3)), - DEFAULT SUBPARTITION other_regions) -( START (2012) END (2015) EVERY (3), - DEFAULT PARTITION outlying_years); -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years" for table "t26002_t1" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2" for table "t26002_t1" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_usa" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_europe" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_asia" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_outlying_years_2_prt_other_regions" for table "t26002_t1_1_prt_outlying_years" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_usa" for table "t26002_t1_1_prt_2" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_europe" for table "t26002_t1_1_prt_2" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_asia" for table "t26002_t1_1_prt_2" -NOTICE: CREATE TABLE will create partition "t26002_t1_1_prt_2_2_prt_other_regions" for table "t26002_t1_1_prt_2" - --- TEST --- expected to see the partition key -\d T26002_T1; - Table "public.t26002_t1" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Number of child tables: 2 (Use \d+ to list them.) -Distributed by: (empid) -Partition by: (year) - -\d t26002_t1_1_prt_2; - Table "public.t26002_t1_1_prt_2" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Check constraints: - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1 -Number of child tables: 4 (Use \d+ to list them.) -Distributed by: (empid) -Partition by: (region, departmentid) - -\d t26002_t1_1_prt_2_2_prt_asia; - Table "public.t26002_t1_1_prt_2_2_prt_asia" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Check constraints: - "t26002_t1_1_prt_2_2_prt_asia_check" CHECK (region::text = 'asia'::text AND departmentid = 3) - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1_1_prt_2 -Distributed by: (empid) - -\d+ T26002_T1; - Table "public.t26002_t1" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Child tables: t26002_t1_1_prt_2, - t26002_t1_1_prt_outlying_years -Has OIDs: no -Distributed by: (empid) -Partition by: (year) - -\d+ t26002_t1_1_prt_2; - Table "public.t26002_t1_1_prt_2" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Check constraints: - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1 -Child tables: t26002_t1_1_prt_2_2_prt_asia, - t26002_t1_1_prt_2_2_prt_europe, - t26002_t1_1_prt_2_2_prt_other_regions, - t26002_t1_1_prt_2_2_prt_usa -Has OIDs: no -Distributed by: (empid) -Partition by: (region, departmentid) - -\d+ t26002_t1_1_prt_2_2_prt_asia; - Table "public.t26002_t1_1_prt_2_2_prt_asia" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Check constraints: - "t26002_t1_1_prt_2_2_prt_asia_check" CHECK (region::text = 'asia'::text AND departmentid = 3) - "t26002_t1_1_prt_2_check" CHECK (year >= 2012 AND year < 2015) -Inherits: t26002_t1_1_prt_2 -Has OIDs: no -Distributed by: (empid) - -/* --- test 2: Data Engineer won't see partition key for non-partitioned table -GIVEN I am a Data Engineer -WHEN I run \d on a non-partitioned table -THEN I should NOT see the partition key in the output -*/ -CREATE TABLE T26002_T2 (empid int, departmentid int, year int, region varchar(20)) -DISTRIBUTED BY (empid); -\d T26002_T2; - Table "public.t26002_t2" - Column | Type | Modifiers ---------------+-----------------------+----------- - empid | integer | - departmentid | integer | - year | integer | - region | character varying(20) | -Distributed by: (empid) - -\d+ T26002_T2; - Table "public.t26002_t2" - Column | Type | Modifiers | Storage | Description ---------------+-----------------------+-----------+----------+------------- - empid | integer | | plain | - departmentid | integer | | plain | - year | integer | | plain | - region | character varying(20) | | extended | -Has OIDs: no -Distributed by: (empid) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS T26002_T1; -DROP TABLE IF EXISTS T26002_T2; --- end_ignore --- ************ORCA ENABLED********** --- --- MPP-23195 --- --- SETUP --- start_ignore -set optimizer_enable_bitmapscan=on; -set optimizer_enable_indexjoin=on; -drop table if exists mpp23195_t1; -NOTICE: table "mpp23195_t1" does not exist, skipping -drop table if exists mpp23195_t2; -NOTICE: table "mpp23195_t2" does not exist, skipping --- end_ignore -create table mpp23195_t1 (i int) partition by range(i) (partition pt1 start(1) end(10), partition pt2 start(10) end(20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "mpp23195_t1_1_prt_pt1" for table "mpp23195_t1" -NOTICE: CREATE TABLE will create partition "mpp23195_t1_1_prt_pt2" for table "mpp23195_t1" -create index index_mpp23195_t1_i on mpp23195_t1(i); -NOTICE: building index for child partition "mpp23195_t1_1_prt_pt1" -NOTICE: building index for child partition "mpp23195_t1_1_prt_pt2" -create table mpp23195_t2(i int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -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 mpp23195_t1 values (generate_series(1,19)); -insert into mpp23195_t2 values (1); --- TEST -select find_operator('explain select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;', 'Dynamic Index Scan'); - find_operator ---------------- - ['true'] -(1 row) - -select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i; - i | i ----+--- -(0 rows) - --- CLEANUP --- start_ignore -drop table if exists mpp23195_t1; -drop table if exists mpp23195_t2; -set optimizer_enable_bitmapscan=off; -set optimizer_enable_indexjoin=off; --- end_ignore ---- ---- Check we have Dynamic Index Scan operator and check we have Nest loop operator ---- --- SETUP --- start_ignore -drop table if exists mpp21834_t1; -NOTICE: table "mpp21834_t1" does not exist, skipping -drop table if exists mpp21834_t2; -NOTICE: table "mpp21834_t2" does not exist, skipping --- end_ignore -create table mpp21834_t1 (i int, j int) partition by range(i) (partition pp1 start(1) end(10), partition pp2 start(10) end(20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "mpp21834_t1_1_prt_pp1" for table "mpp21834_t1" -NOTICE: CREATE TABLE will create partition "mpp21834_t1_1_prt_pp2" for table "mpp21834_t1" -create index index_1 on mpp21834_t1(i); -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp1" -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp2" -create index index_2 on mpp21834_t1(j); -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp1" -NOTICE: building index for child partition "mpp21834_t1_1_prt_pp2" -create table mpp21834_t2(i int, j int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. --- TEST --- start_ignore -select disable_xform('CXformInnerJoin2HashJoin'); - disable_xform --------------------------------------- - CXformInnerJoin2HashJoin is disabled -(1 row) - --- end_ignore -select find_operator('explain analyze select * from mpp21834_t2,mpp21834_t1 where mpp21834_t2.i < mpp21834_t1.i;','Dynamic Index Scan'); - find_operator ---------------- - ['false'] -(1 row) - -select find_operator('explain analyze select * from mpp21834_t2,mpp21834_t1 where mpp21834_t2.i < mpp21834_t1.i;','Nested Loop'); - find_operator ---------------- - ['true'] -(1 row) - --- CLEANUP --- start_ignore -drop index index_2; -WARNING: Only dropped the index "index_2" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop index index_1; -WARNING: Only dropped the index "index_1" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists mpp21834_t2; -drop table if exists mpp21834_t1; -select enable_xform('CXformInnerJoin2HashJoin'); - enable_xform -------------------------------------- - CXformInnerJoin2HashJoin is enabled -(1 row) - --- end_ignore ---- ---- A rescanning of DTS with its own partition selector (under sequence node) ---- --- SETUP --- start_ignore -set optimizer_enable_broadcast_nestloop_outer_child=on; -drop table if exists mpp23288; -NOTICE: table "mpp23288" does not exist, skipping --- end_ignore -create table mpp23288(a int, b int) - partition by range (a) - ( - PARTITION pfirst END(5) INCLUSIVE, - PARTITION pinter START(5) EXCLUSIVE END (10) INCLUSIVE, - PARTITION plast START (10) EXCLUSIVE - ); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "mpp23288_1_prt_pfirst" for table "mpp23288" -NOTICE: CREATE TABLE will create partition "mpp23288_1_prt_pinter" for table "mpp23288" -NOTICE: CREATE TABLE will create partition "mpp23288_1_prt_plast" for table "mpp23288" -insert into mpp23288(a) select generate_series(1,20); -analyze mpp23288; --- TEST -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and t2.a =10) order by t2.a, t1.a;','Dynamic Table Scan'); - count_operator ----------------- - 2 -(1 row) - -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and t2.a =10) order by t2.a, t1.a; - a | a -----+--- - 10 | 1 - 10 | 2 - 10 | 3 - 10 | 4 - 10 | 5 - 10 | 6 - 10 | 7 - 10 | 8 - 10 | 9 -(9 rows) - -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and (t2.a = 10 or t2.a = 5 or t2.a = 12)) order by t2.a, t1.a;','Dynamic Table Scan'); - count_operator ----------------- - 2 -(1 row) - -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and (t2.a = 10 or t2.a = 5 or t2.a = 12)) order by t2.a, t1.a; - a | a -----+---- - 5 | 1 - 5 | 2 - 5 | 3 - 5 | 4 - 10 | 1 - 10 | 2 - 10 | 3 - 10 | 4 - 10 | 5 - 10 | 6 - 10 | 7 - 10 | 8 - 10 | 9 - 12 | 1 - 12 | 2 - 12 | 3 - 12 | 4 - 12 | 5 - 12 | 6 - 12 | 7 - 12 | 8 - 12 | 9 - 12 | 10 - 12 | 11 -(24 rows) - -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on t1.a < t2.a and t2.a = 1 or t2.a < 10 order by t2.a, t1.a;','Dynamic Table Scan'); - count_operator ----------------- - 2 -(1 row) - -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on t1.a < t2.a and t2.a = 1 or t2.a < 10 order by t2.a, t1.a; - a | a ----+---- - 1 | 1 - 1 | 2 - 1 | 3 - 1 | 4 - 1 | 5 - 1 | 6 - 1 | 7 - 1 | 8 - 1 | 9 - 1 | 10 - 1 | 11 - 1 | 12 - 1 | 13 - 1 | 14 - 1 | 15 - 1 | 16 - 1 | 17 - 1 | 18 - 1 | 19 - 1 | 20 - 2 | 1 - 2 | 2 - 2 | 3 - 2 | 4 - 2 | 5 - 2 | 6 - 2 | 7 - 2 | 8 - 2 | 9 - 2 | 10 - 2 | 11 - 2 | 12 - 2 | 13 - 2 | 14 - 2 | 15 - 2 | 16 - 2 | 17 - 2 | 18 - 2 | 19 - 2 | 20 - 3 | 1 - 3 | 2 - 3 | 3 - 3 | 4 - 3 | 5 - 3 | 6 - 3 | 7 - 3 | 8 - 3 | 9 - 3 | 10 - 3 | 11 - 3 | 12 - 3 | 13 - 3 | 14 - 3 | 15 - 3 | 16 - 3 | 17 - 3 | 18 - 3 | 19 - 3 | 20 - 4 | 1 - 4 | 2 - 4 | 3 - 4 | 4 - 4 | 5 - 4 | 6 - 4 | 7 - 4 | 8 - 4 | 9 - 4 | 10 - 4 | 11 - 4 | 12 - 4 | 13 - 4 | 14 - 4 | 15 - 4 | 16 - 4 | 17 - 4 | 18 - 4 | 19 - 4 | 20 - 5 | 1 - 5 | 2 - 5 | 3 - 5 | 4 - 5 | 5 - 5 | 6 - 5 | 7 - 5 | 8 - 5 | 9 - 5 | 10 - 5 | 11 - 5 | 12 - 5 | 13 - 5 | 14 - 5 | 15 - 5 | 16 - 5 | 17 - 5 | 18 - 5 | 19 - 5 | 20 - 6 | 1 - 6 | 2 - 6 | 3 - 6 | 4 - 6 | 5 - 6 | 6 - 6 | 7 - 6 | 8 - 6 | 9 - 6 | 10 - 6 | 11 - 6 | 12 - 6 | 13 - 6 | 14 - 6 | 15 - 6 | 16 - 6 | 17 - 6 | 18 - 6 | 19 - 6 | 20 - 7 | 1 - 7 | 2 - 7 | 3 - 7 | 4 - 7 | 5 - 7 | 6 - 7 | 7 - 7 | 8 - 7 | 9 - 7 | 10 - 7 | 11 - 7 | 12 - 7 | 13 - 7 | 14 - 7 | 15 - 7 | 16 - 7 | 17 - 7 | 18 - 7 | 19 - 7 | 20 - 8 | 1 - 8 | 2 - 8 | 3 - 8 | 4 - 8 | 5 - 8 | 6 - 8 | 7 - 8 | 8 - 8 | 9 - 8 | 10 - 8 | 11 - 8 | 12 - 8 | 13 - 8 | 14 - 8 | 15 - 8 | 16 - 8 | 17 - 8 | 18 - 8 | 19 - 8 | 20 - 9 | 1 - 9 | 2 - 9 | 3 - 9 | 4 - 9 | 5 - 9 | 6 - 9 | 7 - 9 | 8 - 9 | 9 - 9 | 10 - 9 | 11 - 9 | 12 - 9 | 13 - 9 | 14 - 9 | 15 - 9 | 16 - 9 | 17 - 9 | 18 - 9 | 19 - 9 | 20 -(180 rows) - --- CLEANUP --- start_ignore -drop table if exists mpp23288; -set optimizer_enable_broadcast_nestloop_outer_child=off; --- end_ignore ---- ---- Testing whether test gives wrong results with partition tables when sub-partitions are distributed differently than the parent partition. ---- --- SETUP --- start_ignore -drop table if exists pt; -NOTICE: table "pt" does not exist, skipping -drop table if exists t; -NOTICE: table "t" does not exist, skipping --- end_ignore -create table pt(a int, b int, c int) distributed by (a) partition by range(b) (start(0) end(10) every (2)); -NOTICE: CREATE TABLE will create partition "pt_1_prt_1" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_2" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_3" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_4" for table "pt" -NOTICE: CREATE TABLE will create partition "pt_1_prt_5" for table "pt" -alter table pt_1_prt_1 set distributed randomly; -create table t(a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -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 pt select g%10, g%2 + 1, g*2 from generate_series(1,20) g; -insert into pt values(1,1,3); -insert into t select g%10, g%2 + 1 from generate_series(1,20) g; -create index pt_c on pt(c); -NOTICE: building index for child partition "pt_1_prt_1" -NOTICE: building index for child partition "pt_1_prt_2" -NOTICE: building index for child partition "pt_1_prt_3" -NOTICE: building index for child partition "pt_1_prt_4" -NOTICE: building index for child partition "pt_1_prt_5" -analyze t; -analyze pt; --- TEST -SELECT COUNT(*) FROM pt, t WHERE pt.a = t.a; - count -------- - 42 -(1 row) - -SELECT COUNT(*) FROM pt, t WHERE pt.a = t.a and pt.c=4; - count -------- - 2 -(1 row) - -select a, count(*) from pt group by a; - a | count ----+------- - 9 | 2 - 8 | 2 - 2 | 2 - 1 | 3 - 0 | 2 - 3 | 2 - 6 | 2 - 7 | 2 - 5 | 2 - 4 | 2 -(10 rows) - -select b, count(*) from pt group by b; - b | count ----+------- - 1 | 11 - 2 | 10 -(2 rows) - -select a, count(*) from pt where a<2 group by a; - a | count ----+------- - 0 | 2 - 1 | 3 -(2 rows) - --- CLEANUP --- start_ignore -drop index pt_c; -WARNING: Only dropped the index "pt_c" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists pt; -drop table if exists t; --- end_ignore ---- ---- Tests if DynamicIndexScan sets tuple descriptor of the planstate->ps_ResultTupleSlot ---- --- SETUP --- start_ignore -drop table if exists mpp24151_t; -NOTICE: table "mpp24151_t" does not exist, skipping -drop table if exists mpp24151_pt; -NOTICE: table "mpp24151_pt" does not exist, skipping --- end_ignore -create table mpp24151_t(dist int, tid int, t1 text, t2 text); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'dist' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create table mpp24151_pt(dist int, pt1 text, pt2 text, pt3 text, ptid int) -DISTRIBUTED BY (dist) -PARTITION BY RANGE(ptid) - ( - START (0) END (5) EVERY (1), - DEFAULT PARTITION junk_data - ) -; -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_junk_data" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_2" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_3" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_4" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_5" for table "mpp24151_pt" -NOTICE: CREATE TABLE will create partition "mpp24151_pt_1_prt_6" for table "mpp24151_pt" -create index pt1_idx on mpp24151_pt using btree (pt1); -NOTICE: building index for child partition "mpp24151_pt_1_prt_junk_data" -NOTICE: building index for child partition "mpp24151_pt_1_prt_2" -NOTICE: building index for child partition "mpp24151_pt_1_prt_3" -NOTICE: building index for child partition "mpp24151_pt_1_prt_4" -NOTICE: building index for child partition "mpp24151_pt_1_prt_5" -NOTICE: building index for child partition "mpp24151_pt_1_prt_6" -create index ptid_idx on mpp24151_pt using btree (ptid); -NOTICE: building index for child partition "mpp24151_pt_1_prt_junk_data" -NOTICE: building index for child partition "mpp24151_pt_1_prt_2" -NOTICE: building index for child partition "mpp24151_pt_1_prt_3" -NOTICE: building index for child partition "mpp24151_pt_1_prt_4" -NOTICE: building index for child partition "mpp24151_pt_1_prt_5" -NOTICE: building index for child partition "mpp24151_pt_1_prt_6" -insert into mpp24151_pt select i, 'hello' || 0, 'world', 'drop this', i % 6 from generate_series(0,100)i; -insert into mpp24151_pt select i, 'hello' || i, 'world', 'drop this', i % 6 from generate_series(0,200000)i; -insert into mpp24151_t select i, i % 6, 'hello' || i, 'bar' from generate_series(0,10)i; -analyze mpp24151_pt; -analyze mpp24151_t; --- TEST --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan'); - disable_xform ------------------------------------------------ - CXformDynamicGet2DynamicTableScan is disabled -(1 row) - --- end_ignore -select count_operator('explain select * from mpp24151_t, mpp24151_pt where tid = ptid and pt1 = \'hello0\';','Result'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from mpp24151_t, mpp... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 0 -(1 row) - -select * from mpp24151_t, mpp24151_pt where tid = ptid and pt1 = 'hello0'; - dist | tid | t1 | t2 | dist | pt1 | pt2 | pt3 | ptid -------+-----+---------+-----+------+--------+-------+-----------+------ - 0 | 0 | hello0 | bar | 0 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 30 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 36 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 48 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 72 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 84 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 0 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 12 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 24 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 60 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 66 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 78 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 6 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 18 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 42 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 54 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 90 | hello0 | world | drop this | 0 - 0 | 0 | hello0 | bar | 96 | hello0 | world | drop this | 0 - 1 | 1 | hello1 | bar | 1 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 13 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 31 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 37 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 49 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 85 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 25 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 43 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 61 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 67 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 79 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 7 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 19 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 55 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 73 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 91 | hello0 | world | drop this | 1 - 1 | 1 | hello1 | bar | 97 | hello0 | world | drop this | 1 - 2 | 2 | hello2 | bar | 2 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 14 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 50 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 68 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 86 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 8 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 26 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 32 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 44 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 62 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 80 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 92 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 98 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 20 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 38 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 56 | hello0 | world | drop this | 2 - 2 | 2 | hello2 | bar | 74 | hello0 | world | drop this | 2 - 6 | 0 | hello6 | bar | 0 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 30 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 36 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 48 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 72 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 84 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 0 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 12 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 24 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 60 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 66 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 78 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 6 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 18 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 42 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 54 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 90 | hello0 | world | drop this | 0 - 6 | 0 | hello6 | bar | 96 | hello0 | world | drop this | 0 - 7 | 1 | hello7 | bar | 1 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 13 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 31 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 37 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 49 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 85 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 25 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 43 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 61 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 67 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 79 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 7 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 19 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 55 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 73 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 91 | hello0 | world | drop this | 1 - 7 | 1 | hello7 | bar | 97 | hello0 | world | drop this | 1 - 8 | 2 | hello8 | bar | 2 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 14 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 50 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 68 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 86 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 8 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 26 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 32 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 44 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 62 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 80 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 92 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 98 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 20 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 38 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 56 | hello0 | world | drop this | 2 - 8 | 2 | hello8 | bar | 74 | hello0 | world | drop this | 2 - 3 | 3 | hello3 | bar | 15 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 33 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 51 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 63 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 69 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 9 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 27 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 45 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 81 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 93 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 99 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 3 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 21 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 39 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 57 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 75 | hello0 | world | drop this | 3 - 3 | 3 | hello3 | bar | 87 | hello0 | world | drop this | 3 - 4 | 4 | hello4 | bar | 16 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 28 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 34 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 52 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 70 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 10 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 46 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 58 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 64 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 82 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 94 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 100 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 4 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 22 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 40 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 76 | hello0 | world | drop this | 4 - 4 | 4 | hello4 | bar | 88 | hello0 | world | drop this | 4 - 5 | 5 | hello5 | bar | 17 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 29 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 35 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 71 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 83 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 11 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 23 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 47 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 59 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 65 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 95 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 5 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 41 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 53 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 77 | hello0 | world | drop this | 5 - 5 | 5 | hello5 | bar | 89 | hello0 | world | drop this | 5 - 9 | 3 | hello9 | bar | 15 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 33 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 51 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 63 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 69 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 9 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 27 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 45 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 81 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 93 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 99 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 3 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 21 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 39 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 57 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 75 | hello0 | world | drop this | 3 - 9 | 3 | hello9 | bar | 87 | hello0 | world | drop this | 3 - 10 | 4 | hello10 | bar | 16 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 28 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 34 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 52 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 70 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 10 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 46 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 58 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 64 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 82 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 94 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 100 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 4 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 22 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 40 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 76 | hello0 | world | drop this | 4 - 10 | 4 | hello10 | bar | 88 | hello0 | world | drop this | 4 -(188 rows) - --- CLEANUP --- start_ignore -drop index ptid_idx; -WARNING: Only dropped the index "ptid_idx" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop index pt1_idx; -WARNING: Only dropped the index "pt1_idx" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists mpp24151_t; -drop table if exists mpp24151_pt; -select enable_xform('CXformDynamicGet2DynamicTableScan'); - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - --- end_ignore ---- ---- No DPE (Dynamic Partition Elimination) on second child of a union under a join ---- --- SETUP --- start_ignore -drop table if exists t; -NOTICE: table "t" does not exist, skipping -drop table if exists p1; -NOTICE: table "p1" does not exist, skipping -drop table if exists p2; -NOTICE: table "p2" does not exist, skipping -drop table if exists p3; -NOTICE: table "p3" does not exist, skipping -drop table if exists p; -NOTICE: table "p" does not exist, skipping --- end_ignore -create table p1 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "p1_1_prt_1" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_2" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_3" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_4" for table "p1" -NOTICE: CREATE TABLE will create partition "p1_1_prt_5" for table "p1" -create table p2 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "p2_1_prt_1" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_2" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_3" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_4" for table "p2" -NOTICE: CREATE TABLE will create partition "p2_1_prt_5" for table "p2" -create table p3 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "p3_1_prt_1" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_2" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_3" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_4" for table "p3" -NOTICE: CREATE TABLE will create partition "p3_1_prt_5" for table "p3" -create table p (a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -create table t(a int, b int); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -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 select g, g*10 from generate_series(1,100) g; -insert into p1 select g, g%99 +1 from generate_series(1,10000) g; -insert into p2 select g, g%99 +1 from generate_series(1,10000) g; -insert into p3 select g, g%99 +1 from generate_series(1,10000) g; -insert into p select g, g%99 +1 from generate_series(1,10000) g; -analyze t; -analyze p1; -analyze p2; -analyze p3; -analyze p; --- TEST -select count_operator('explain select * from (select * from p1 union all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 except all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 except select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 intersect all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2 union all select * from p3) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 3 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2 union all select * from p) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p union all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p2 intersect all select * from p3) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 3 -(1 row) - -select count_operator('explain select * from (select * from p1 union select * from p intersect all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - count_operator ----------------- - 2 -(1 row) - --- CLEANUP --- start_ignore -drop table t; -drop table p1; -drop table p2; -drop table p3; -drop table p; --- end_ignore ---- ---- Gracefully handle NULL partition set from BitmapTableScan, DynamicTableScan and DynamicIndexScan ---- --- SETUP --- start_ignore -drop table if exists dts; -NOTICE: table "dts" does not exist, skipping -drop table if exists dis; -NOTICE: table "dis" does not exist, skipping -drop table if exists dbs; -NOTICE: table "dbs" does not exist, skipping --- end_ignore -create table dts(c1 int, c2 int) partition by range(c2) (start(1) end(11) every(1)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "dts_1_prt_1" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_2" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_3" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_4" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_5" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_6" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_7" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_8" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_9" for table "dts" -NOTICE: CREATE TABLE will create partition "dts_1_prt_10" for table "dts" -create table dis(c1 int, c2 int, c3 int) partition by range(c2) (start(1) end(11) every(1)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "dis_1_prt_1" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_2" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_3" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_4" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_5" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_6" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_7" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_8" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_9" for table "dis" -NOTICE: CREATE TABLE will create partition "dis_1_prt_10" for table "dis" -create index dis_index on dis(c3); -NOTICE: building index for child partition "dis_1_prt_1" -NOTICE: building index for child partition "dis_1_prt_2" -NOTICE: building index for child partition "dis_1_prt_3" -NOTICE: building index for child partition "dis_1_prt_4" -NOTICE: building index for child partition "dis_1_prt_5" -NOTICE: building index for child partition "dis_1_prt_6" -NOTICE: building index for child partition "dis_1_prt_7" -NOTICE: building index for child partition "dis_1_prt_8" -NOTICE: building index for child partition "dis_1_prt_9" -NOTICE: building index for child partition "dis_1_prt_10" -CREATE TABLE dbs(c1 int, c2 int, c3 int) partition by range(c2) (start(1) end(11) every(1)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "dbs_1_prt_1" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_2" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_3" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_4" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_5" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_6" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_7" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_8" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_9" for table "dbs" -NOTICE: CREATE TABLE will create partition "dbs_1_prt_10" for table "dbs" -create index dbs_index on dbs using bitmap(c3); -NOTICE: building index for child partition "dbs_1_prt_1" -NOTICE: building index for child partition "dbs_1_prt_2" -NOTICE: building index for child partition "dbs_1_prt_3" -NOTICE: building index for child partition "dbs_1_prt_4" -NOTICE: building index for child partition "dbs_1_prt_5" -NOTICE: building index for child partition "dbs_1_prt_6" -NOTICE: building index for child partition "dbs_1_prt_7" -NOTICE: building index for child partition "dbs_1_prt_8" -NOTICE: building index for child partition "dbs_1_prt_9" -NOTICE: building index for child partition "dbs_1_prt_10" --- TEST -select find_operator('explain (select * from dts where c2 = 1) union (select * from dts where c2 = 2) union (select * from dts where c2 = 3) union (select * from dts where c2 = 4) union (select * from dts where c2 = 5) union (select * from dts where c2 = 6) union (select * from dts where c2 = 7) union (select * from dts where c2 = 8) union (select * from dts where c2 = 9) union (select * from dts where c2 = 10);', 'Dynamic Table Scan'); - find_operator ---------------- - ['true'] -(1 row) - -(select * from dts where c2 = 1) union -(select * from dts where c2 = 2) union -(select * from dts where c2 = 3) union -(select * from dts where c2 = 4) union -(select * from dts where c2 = 5) union -(select * from dts where c2 = 6) union -(select * from dts where c2 = 7) union -(select * from dts where c2 = 8) union -(select * from dts where c2 = 9) union -(select * from dts where c2 = 10); - c1 | c2 -----+---- -(0 rows) - --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan'); - disable_xform ------------------------------------------------ - CXformDynamicGet2DynamicTableScan is disabled -(1 row) - --- end_ignore -select find_operator('explain (select * from dis where c3 = 1) union (select * from dis where c3 = 2) union (select * from dis where c3 = 3) union (select * from dis where c3 = 4) union (select * from dis where c3 = 5) union (select * from dis where c3 = 6) union (select * from dis where c3 = 7) union (select * from dis where c3 = 8) union (select * from dis where c3 = 9) union (select * from dis where c3 = 10);', 'Dynamic Index Scan'); - find_operator ---------------- - ['true'] -(1 row) - -(select * from dis where c3 = 1) union -(select * from dis where c3 = 2) union -(select * from dis where c3 = 3) union -(select * from dis where c3 = 4) union -(select * from dis where c3 = 5) union -(select * from dis where c3 = 6) union -(select * from dis where c3 = 7) union -(select * from dis where c3 = 8) union -(select * from dis where c3 = 9) union -(select * from dis where c3 = 10); - c1 | c2 | c3 -----+----+---- -(0 rows) - -select find_operator('explain select * from dbs where c2= 15 and c3 = 5;', 'Bitmap Table Scan'); - find_operator ---------------- - ['false'] -(1 row) - -select * from dbs where c2= 15 and c3 = 5; - c1 | c2 | c3 -----+----+---- -(0 rows) - --- CLEANUP --- start_ignore -drop index dbs_index; -WARNING: Only dropped the index "dbs_index" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists dbs; -drop index dis_index; -WARNING: Only dropped the index "dis_index" -HINT: To drop other indexes on child partitions, drop each one explicitly. -drop table if exists dis; -drop table if exists dts; -select enable_xform('CXformDynamicGet2DynamicTableScan'); - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - --- end_ignore ---- ---- Partition elimination for heterogenous DynamicIndexScans ---- --- SETUP --- start_ignore -drop table if exists pp; -NOTICE: table "pp" does not exist, skipping -drop index if exists pp_1_prt_1_idx; -NOTICE: index "pp_1_prt_1_idx" does not exist, skipping -drop index if exists pp_rest_1_idx; -NOTICE: index "pp_rest_1_idx" does not exist, skipping -drop index if exists pp_rest_2_idx; -NOTICE: index "pp_rest_2_idx" does not exist, skipping -set optimizer_segments=2; -set optimizer_partition_selection_log=on; --- end_ignore -create table pp(a int, b int, c int) partition by range(b) (start(1) end(15) every(5)); -NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. -HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. -NOTICE: CREATE TABLE will create partition "pp_1_prt_1" for table "pp" -NOTICE: CREATE TABLE will create partition "pp_1_prt_2" for table "pp" -NOTICE: CREATE TABLE will create partition "pp_1_prt_3" for table "pp" -insert into pp values (1,1,2),(2,6,2), (3,11,2); --- Heterogeneous Index on the partition table -create index pp_1_prt_1_idx on pp_1_prt_1(c); --- Create other indexes so that we can automate the repro for MPP-21069 by disabling tablescan -create index pp_rest_1_idx on pp_1_prt_2(c,a); -create index pp_rest_2_idx on pp_1_prt_3(c,a); --- TEST --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan') ; - disable_xform ------------------------------------------------ - CXformDynamicGet2DynamicTableScan is disabled -(1 row) - --- end_ignore -select * from pp where b=2 and c=2; - a | b | c ----+---+--- -(0 rows) - -select count_operator('explain select * from pp where b=2 and c=2;','Partition Selector'); -WARNING: bogus var: varno=65000 varattno=2 (ruleutils.c:3186) -CONTEXT: SQL statement "explain select * from pp where b=2 and c=2;" -PL/Python function "count_operator" - count_operator ----------------- - 1 -(1 row) - --- CLEANUP --- start_ignore -drop index if exists pp_rest_2_idx; -drop index if exists pp_rest_1_idx; -drop index if exists pp_1_prt_1_idx; -drop table if exists pp; -select enable_xform('CXformDynamicGet2DynamicTableScan') ; - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - -reset optimizer_segments; -set optimizer_partition_selection_log=off; -select enable_xform('CXformDynamicGet2DynamicTableScan') ; - enable_xform ----------------------------------------------- - CXformDynamicGet2DynamicTableScan is enabled -(1 row) - --- end_ignore ---- ---- Partition elimination with implicit CAST on the partitioning key ---- --- SETUP --- start_ignore -set optimizer_segments=2; -set optimizer_partition_selection_log=on; -DROP TABLE IF EXISTS ds_4; -NOTICE: table "ds_4" does not exist, skipping --- end_ignore -CREATE TABLE ds_4 -( - month_id character varying(6), - cust_group_acc numeric(10), - mobile_no character varying(10) -) -DISTRIBUTED BY (cust_group_acc, mobile_no) -PARTITION BY LIST(month_id) - ( - PARTITION p200800 VALUES('200800'), - PARTITION p200801 VALUES('200801'), - PARTITION p200802 VALUES('200802'), - PARTITION p200803 VALUES('200803') -); -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200800" for table "ds_4" -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200801" for table "ds_4" -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200802" for table "ds_4" -NOTICE: CREATE TABLE will create partition "ds_4_1_prt_p200803" for table "ds_4" --- TEST -select * from ds_4 where month_id = '200800'; - month_id | cust_group_acc | mobile_no -----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 where month_id = \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 where mont... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 1 -(1 row) - -select * from ds_4 where month_id > '200800'; - month_id | cust_group_acc | mobile_no -----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 where month_id > \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 where mont... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 1 -(1 row) - -select * from ds_4 where month_id <= '200800'; - month_id | cust_group_acc | mobile_no -----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 where month_id <= \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 where mont... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 1 -(1 row) - -select * from ds_4 a1,ds_4 a2 where a1.month_id = a2.month_id and a1.month_id > '200800'; - month_id | cust_group_acc | mobile_no | month_id | cust_group_acc | mobile_no -----------+----------------+-----------+----------+----------------+----------- -(0 rows) - -select count_operator('explain select * from ds_4 a1,ds_4 a2 where a1.month_id = a2.month_id and a1.month_id > \'200800\';','Partition Selector'); -WARNING: nonstandard use of \' in a string literal -LINE 1: select count_operator('explain select * from ds_4 a1,ds_4 a2... - ^ -HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). - count_operator ----------------- - 2 -(1 row) - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS ds_4; -set optimizer_partition_selection_log=off; -reset optimizer_segments; -drop function if exists find_operator(query text, operator_name text); -drop function if exists count_operator(query text, operator_name text); -drop language if exists plpythonu; --- end_ignore diff --git a/src/test/regress/greenplum_schedule b/src/test/regress/greenplum_schedule index 4807104876f4d12269f5bd6f8e5faecfa92e3a2c..98ab69aba5cdf4899e3b8ae8f6d6cf67a5042f61 100755 --- a/src/test/regress/greenplum_schedule +++ b/src/test/regress/greenplum_schedule @@ -72,9 +72,10 @@ test: gp_toolkit test: filespace trig auth_constraint role rle portals_updatable plpgsql_cache timeseries resource_queue_function pg_stat_last_operation gp_numeric_agg plan_size partindex_test direct_dispatch partition_pruning_with_fn dsp +# direct dispatch tests test: bfv_dd bfv_dd_multicolumn bfv_dd_types -test: catalog bfv_catalog bfv_index bfv_olap bfv_aggregate bfv_partition +test: catalog bfv_catalog bfv_index test: aggregate_with_groupingsets gp_optimizer diff --git a/src/test/regress/sql/bfv_aggregate.sql b/src/test/regress/sql/bfv_aggregate.sql deleted file mode 100644 index d3906be0d78bfe7775d533095c92af66db48b01d..0000000000000000000000000000000000000000 --- a/src/test/regress/sql/bfv_aggregate.sql +++ /dev/null @@ -1,254 +0,0 @@ ---- ---- Window function with outer references in PARTITION BY/ORDER BY clause ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS x_outer; -DROP TABLE IF EXISTS y_inner; --- end_ignore -create table x_outer (a int, b int, c int); -create table y_inner (d int, e int); -insert into x_outer select i%3, i, i from generate_series(1,10) i; -insert into y_inner select i%3, i from generate_series(1,10) i; -analyze x_outer; -analyze y_inner; - --- TEST -select * from x_outer where a in (select row_number() over(partition by a) from y_inner) order by 1, 2; - -select * from x_outer where a in (select rank() over(order by a) from y_inner) order by 1, 2; - -select * from x_outer where a not in (select rank() over(order by a) from y_inner) order by 1, 2; - -select * from x_outer where exists (select rank() over(order by a) from y_inner where d = a) order by 1, 2; - -select * from x_outer where not exists (select rank() over(order by a) from y_inner where d = a) order by 1, 2; - -select * from x_outer where a in (select last_value(d) over(partition by b order by e rows between e preceding and e+1 following) from y_inner) order by 1, 2; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS x_outer; -DROP TABLE IF EXISTS y_inner; --- end_ignore - ---- ---- Testing aggregation in a query ---- - --- SETUP -create table d (col1 timestamp, col2 int); -insert into d select to_date('2014-01-01', 'YYYY-DD-MM'), generate_series(1,100); - --- TEST -select 1, to_char(col1, 'YYYY'), median(col2) from d group by 1, 2; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS d; --- end_ignore - ---- ---- Testing if aggregate derived window function produces incorrect results ---- - --- SETUP --- start_ignore -drop table if exists toy; -drop aggregate mysum1(int4); -drop aggregate mysum2(int4); --- end_ignore -create table toy(id,val) as select i,i from generate_series(1,5) i; -create aggregate mysum1(int4) (sfunc = int4_sum, prefunc=int8pl, stype=bigint); -create aggregate mysum2(int4) (sfunc = int4_sum, stype=bigint); - --- TEST -select - id, val, - sum(val) over (w), - mysum1(val) over (w), - mysum2(val) over (w) -from toy -window w as (order by id rows 2 preceding); - --- CLEANUP --- start_ignore -drop table if exists toy; -drop aggregate mysum1(int4); -drop aggregate mysum2(int4); --- end_ignore - ---- ---- Error executing for aggregate with anyarry as return type ---- - --- SETUP -CREATE OR REPLACE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS -'select $1 || $2' LANGUAGE SQL; - -CREATE OR REPLACE FUNCTION ffp(anyarray) RETURNS anyarray AS -'select $1' LANGUAGE SQL; - -CREATE AGGREGATE myaggp20a(BASETYPE = anyelement, SFUNC = tfp, - STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}'); - --- Adding a sql function to sory the array -CREATE OR REPLACE FUNCTION array_sort (ANYARRAY) -RETURNS ANYARRAY LANGUAGE SQL -AS $$ -SELECT ARRAY(SELECT unnest($1) ORDER BY 1) -$$; - -create temp table t(f1 int, f2 int[], f3 text); - --- TEST -insert into t values(1,array[1],'a'); -insert into t values(1,array[11],'b'); -insert into t values(1,array[111],'c'); -insert into t values(2,array[2],'a'); -insert into t values(2,array[22],'b'); -insert into t values(2,array[222],'c'); -insert into t values(3,array[3],'a'); -insert into t values(3,array[3],'b'); - -select f3, array_sort(myaggp20a(f1)) from t group by f3 order by f3; - --- CLEANUP --- start_ignore -drop table if exists t; -drop function array_sort (ANYARRAY) cascade; -drop function tfp(anyarray,anyelement) cascade; -drop function ffp(anyarray) cascade; --- end_ignore - --- start_ignore --- start_ignore -drop language if exists plpythonu; -create language plpythonu; --- end_ignore -create or replace function count_operator(explain_query text, operator text) returns int as -$$ -rv = plpy.execute(explain_query) -search_text = operator -result = 0 -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = result+1 -return result -$$ -language plpythonu; - ---- ---- Testing adding a traceflag to favor multi-stage aggregation ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS multi_stage_test; --- end_ignore -create table multi_stage_test(a int, b int); -insert into multi_stage_test select i, i%4 from generate_series(1,10) i; -analyze multi_stage_test; - --- TEST --- start_ignore -set optimizer_segments=2; -set optimizer_prefer_multistage_agg = on; --- end_ignore -select count_operator('explain select count(*) from multi_stage_test group by b;','GroupAggregate'); --- start_ignore -set optimizer_prefer_multistage_agg = off; --- end_ignore -select count_operator('explain select count(*) from multi_stage_test group by b;','GroupAggregate'); - ---CLEANUP --- start_ignore -DROP TABLE IF EXISTS multi_stage_test; -reset optimizer_segments; -set optimizer_prefer_multistage_agg = off; --- end_ignore - ---- ---- Testing not picking HashAgg for aggregates without preliminary functions ---- - --- SETUP --- start_ignore -SET optimizer_disable_missing_stats_collection=on; -DROP TABLE IF EXISTS attribute_table; --- end_ignore -CREATE TABLE attribute_table (product_id integer, attribute_id integer,attribute text, attribute2 text,attribute_ref_lists text,short_name text,attribute6 text,attribute5 text,measure double precision,unit character varying(60)) DISTRIBUTED BY (product_id ,attribute_id); --- create the transition function -CREATE OR REPLACE FUNCTION do_concat(text,text) -RETURNS text ---concatenates 2 strings -AS 'SELECT CASE WHEN $1 IS NULL THEN $2 -WHEN $2 IS NULL THEN $1 -ELSE $1 || $2 END;' - LANGUAGE SQL - IMMUTABLE - RETURNS NULL ON NULL INPUT; --- UDA definition. No PREFUNC exists --- start_ignore -DROP AGGREGATE IF EXISTS concat(text); --- end_ignore -CREATE AGGREGATE concat(text) ( - --text/string concatenation - SFUNC = do_concat, --Function to call for each string that builds the aggregate - STYPE = text,--FINALFUNC=final_func, --Function to call after everything has been aggregated - INITCOND = '' --Initialize as an empty string when starting -); - --- TEST --- cook some stats --- start_ignore -set allow_system_table_mods='DML'; --- end_ignore -UPDATE pg_class set reltuples=524592::real, relpages=2708::integer where oid = 'attribute_table'::regclass; -select count_operator('explain select product_id,concat(E''#attribute_''||attribute_id::varchar||E'':''||attribute) as attr FROM attribute_table GROUP BY product_id;','HashAggregate'); - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS attribute_table; -DROP AGGREGATE IF EXISTS concat(text); -drop function do_concat(text,text) cascade; -SET optimizer_disable_missing_stats_collection=off; --- end_ignore - - ---- ---- Testing fallback to planner when the agg used in window does not have either prelim or inverse prelim function. ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS foo; --- end_ignore -create table foo(a int, b text) distributed by (a); - --- TEST -insert into foo values (1,'aaa'), (2,'bbb'), (3,'ccc'); --- should fall back -select string_agg(b) over (partition by a) from foo order by 1; -select string_agg(b) over (partition by a,b) from foo order by 1; --- should not fall back -select max(b) over (partition by a) from foo order by 1; -select count_operator('explain select max(b) over (partition by a) from foo order by 1;', 'Table Scan'); --- fall back -select string_agg(b) over (partition by a+1) from foo order by 1; -select string_agg(b || 'txt') over (partition by a) from foo order by 1; -select string_agg(b || 'txt') over (partition by a+1) from foo order by 1; --- fall back and planner's plan produces unsupported execution -select string_agg(b) over (partition by a order by a) from foo order by 1; -select string_agg(b || 'txt') over (partition by a,b order by a,b) from foo order by 1; -select '1' || string_agg(b) over (partition by a+1 order by a+1) from foo; - --- CLEANUP --- start_ignore -drop function count_operator(text,text); -DROP TABLE IF EXISTS foo; -drop function if exists count_operator(explain_query text, operator text); -drop language if exists plpythonu; --- end_ignore diff --git a/src/test/regress/sql/bfv_olap.sql b/src/test/regress/sql/bfv_olap.sql deleted file mode 100644 index c10b41441fccc3f142482f7304ec69b22c30470e..0000000000000000000000000000000000000000 --- a/src/test/regress/sql/bfv_olap.sql +++ /dev/null @@ -1,413 +0,0 @@ ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- - --- SETUP --- start_ignore -drop table if exists toy; -drop aggregate if exists mysum1(int4); -drop aggregate if exists mysum2(int4); --- end_ignore -create table toy(id,val) as select i,i from generate_series(1,5) i; -create aggregate mysum1(int4) (sfunc = int4_sum, prefunc=int8pl, stype=bigint); -create aggregate mysum2(int4) (sfunc = int4_sum, stype=bigint); - --- TEST -select id, val, sum(val) over (w), mysum1(val) over (w), mysum2(val) over (w) from toy window w as (order by id rows 2 preceding); - --- CLEANUP --- start_ignore -drop aggregate if exists mysum1(int4); -drop aggregate if exists mysum2(int4); -drop table if exists toy; --- end_ignore - ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- - --- SETUP --- start_ignore -drop type if exists ema_type cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop function if exists ema_fin(t ema_type) cascade; -drop aggregate if exists ema(float, float); -drop table if exists ema_test cascade; --- end_ignore -create type ema_type as (x float, e float); - -create function ema_adv(t ema_type, v float, x float) - returns ema_type - as $$ - begin - if t.e is null then - t.e = v; - t.x = x; - else - if t.x != x then - raise exception 'ema smoothing x may not vary'; - end if; - t.e = t.e + (v - t.e) * t.x; - end if; - return t; - end; - $$ language plpgsql; - -create function ema_fin(t ema_type) - returns float - as $$ - begin - return t.e; - end; - $$ language plpgsql; - -create aggregate ema(float, float) ( - sfunc = ema_adv, - stype = ema_type, - finalfunc = ema_fin, - initcond = '(,)'); - -create table ema_test (k int, v float ) distributed by (k); -insert into ema_test select i, 4*random() + 10.0*(1+cos(radians(i*5))) from generate_series(0,19) i(i); - --- TEST -select k, v, ema(v, 0.9) over (order by k rows between unbounded preceding and current row) from ema_test order by k; - --- CLEANUP --- start_ignore -drop table if exists ema_test cascade; -drop aggregate if exists ema(float, float); -drop function if exists ema_fin(t ema_type) cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop type if exists ema_type cascade; --- end_ignore - ---- ---- Test case errors out when we define aggregates without preliminary functions and use it as an aggregate derived window function. ---- - --- SETUP --- start_ignore -drop type if exists ema_type cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop function if exists ema_fin(t ema_type) cascade; -drop aggregate if exists ema(float, float); -drop table if exists ema_test cascade; --- end_ignore -create type ema_type as (x float, e float); - -create function ema_adv(t ema_type, v float, x float) - returns ema_type - as $$ - begin - if t.e is null then - t.e = v; - t.x = x; - else - if t.x != x then - raise exception 'ema smoothing x may not vary'; - end if; - t.e = t.e + (v - t.e) * t.x; - end if; - return t; - end; - $$ language plpgsql; - -create function ema_fin(t ema_type) - returns float - as $$ - begin - return t.e; - end; - $$ language plpgsql; - -create aggregate ema(float, float) ( - sfunc = ema_adv, - stype = ema_type, - finalfunc = ema_fin, - initcond = '(,)'); - -create table ema_test (k int, v float ) distributed by (k); -insert into ema_test select i, 4*random() + 10.0*(1+cos(radians(i*5))) from generate_series(0,19) i(i); - --- TEST -select k, v, ema(v, 0.9) over (order by k) from ema_test order by k; - --- CLEANUP --- start_ignore -drop table if exists ema_test cascade; -drop aggregate if exists ema(float, float); -drop function if exists ema_fin(t ema_type) cascade; -drop function if exists ema_adv(t ema_type, v float, x float) cascade; -drop type if exists ema_type cascade; --- end_ignore - - - - - - - ---- ---- Test with/without group by ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); - ---TEST -SELECT MAX(a) AS m FROM r GROUP BY b ORDER BY m; -SELECT MAX(a) AS m FROM r GROUP BY a ORDER BY m; -SELECT MAX(a) AS m FROM r GROUP BY b; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore - - ---- ---- ORDER BY clause includes some grouping column or not ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); - ---TEST -SELECT MAX(a) AS m FROM R GROUP BY b ORDER BY m,b; -SELECT MAX(a) AS m FROM R GROUP BY b,e ORDER BY m,b,e; -SELECT MAX(a) AS m FROM R GROUP BY b,e ORDER BY m; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore - - ---- ---- ORDER BY 1 or more columns ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore -CREATE TABLE r -( - a INT NOT NULL, - b INT, - c CHARACTER VARYING(200), - d NUMERIC(10,0), - e DATE -) DISTRIBUTED BY (a,b); -ALTER TABLE r ADD CONSTRAINT PKEY PRIMARY KEY (b); - ---TEST -SELECT MAX(a),d,e AS m FROM r GROUP BY b,d,e ORDER BY m,e,d; -SELECT MIN(a),d,e AS m FROM r GROUP BY b,e,d ORDER BY e,d; -SELECT MAX(a) AS m FROM r GROUP BY b,c,d,e ORDER BY e,d; -SELECT MAX(a) AS m FROM r GROUP BY b,e ORDER BY e; -SELECT MAX(e) AS m FROM r GROUP BY b ORDER BY m; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS r; --- end_ignore - - ---- ---- ORDER BY clause includes some grouping column or not ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS dm_calendar; --- end_ignore -CREATE TABLE dm_calendar ( - calendar_id bigint NOT NULL, - date_name character varying(200), - date_name_cn character varying(200), - calendar_date date, - current_day numeric(10,0), - month_id numeric(10,0), - month_name character varying(200), - month_name_cn character varying(200), - month_name_short character varying(200), - month_name_short_cn character varying(200), - days_in_month numeric(10,0), - first_of_month numeric(10,0), - last_month_id numeric(10,0), - month_end numeric(10,0), - quarter_id numeric(10,0), - quarter_name character varying(200), - quarter_name_cn character varying(200), - quarter_name_short character varying(200), - quarter_name_short_cn character varying(200), - year_id numeric(10,0), - year_name character varying(200), - year_name_cn character varying(200), - description character varying(500), - create_date timestamp without time zone, - month_week_num character varying(100), - month_week_begin character varying(100), - month_week_end character varying(100), - half_year character varying(100), - weekend_flag character varying(100), - holidays_flag character varying(100), - workday_flag character varying(100), - month_number numeric(10,0) -) DISTRIBUTED BY (calendar_id); -ALTER TABLE ONLY dm_calendar ADD CONSTRAINT dm_calendar_pkey PRIMARY KEY (calendar_id); - ---TEST -SELECT "year_id" as id , min("year_name") as a from (select "year_id" as "year_id" , min("year_name") as "year_name" from "dm_calendar" group by "year_id") "dm_calendar3" group by "year_id" order by a ASC ; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS dm_calendar; --- end_ignore - - ---- ---- Test with/without group by with primary key as dist key ---- - --- SETUP --- start_ignore -drop table if exists t; --- end_ignore -create table t -( - a int NOT NULL, - b int, - c character varying(200), - d numeric(10,0), - e date -) distributed by (b); -alter table t ADD CONSTRAINT pkey primary key (b); - --- TEST -SELECT MAX(a) AS m FROM t GROUP BY b ORDER BY m; - --- CLEANUP --- start_ignore -drop table if exists t; --- end_ignore - - - - ---- ---- Passing through distribution matching type in default implementation ---- - --- SETUP --- start_ignore -drop table if exists customer; -drop table if exists sale; --- end_ignore -create table customer -( - cn int not null, - cname text not null, - cloc text, - - primary key (cn) - -) distributed by (cn); - - -insert into customer values - ( 1, 'Macbeth', 'Inverness'), - ( 2, 'Duncan', 'Forres'), - ( 3, 'Lady Macbeth', 'Inverness'), - ( 4, 'Witches, Inc', 'Lonely Heath'); - - -create table sale -( - cn int not null, - vn int not null, - pn int not null, - dt date not null, - qty int not null, - prc float not null, - - primary key (cn, vn, pn) - -) distributed by (cn,vn,pn); - - -insert into sale values - ( 2, 40, 100, '1401-1-1', 1100, 2400), - ( 1, 10, 200, '1401-3-1', 1, 0), - ( 3, 40, 200, '1401-4-1', 1, 0), - ( 1, 20, 100, '1401-5-1', 1, 0), - ( 1, 30, 300, '1401-5-2', 1, 0), - ( 1, 50, 400, '1401-6-1', 1, 0), - ( 2, 50, 400, '1401-6-1', 1, 0), - ( 1, 30, 500, '1401-6-1', 12, 5), - ( 3, 30, 500, '1401-6-1', 12, 5), - ( 3, 30, 600, '1401-6-1', 12, 5), - ( 4, 40, 700, '1401-6-1', 1, 1), - ( 4, 40, 800, '1401-6-1', 1, 1); - --- TEST -select cname, -rank() over (partition by sale.cn order by vn) -from sale, customer -where sale.cn = customer.cn -order by 1, 2; - --- CLEANUP --- start_ignore -drop table if exists customer; -drop table if exists sale; --- end_ignore - - ---- ---- Optimzier query crashing for logical window with no window functions ---- - --- SETUP -create table mpp23240(a int, b int, c int, d int, e int, f int); - --- TEST -select a, b, - case 1 - when 10 then - sum(c) over(partition by a) - when 20 then - sum(d) over(partition by a) - else - 5 - end as sum1 -from (select * from mpp23240 where f > 10) x; - --- CLEANUP --- start_ignore -drop table mpp23240; --- end_ignore diff --git a/src/test/regress/sql/bfv_partition.sql b/src/test/regress/sql/bfv_partition.sql deleted file mode 100644 index 9b8d5df0ffcdb0ddb1dc72694be7d50884d8e47c..0000000000000000000000000000000000000000 --- a/src/test/regress/sql/bfv_partition.sql +++ /dev/null @@ -1,644 +0,0 @@ ---- ---- Initial setup for all the partitioning test for this suite ---- --- start_ignore -drop language if exists plpythonu; -create language plpythonu; --- end_ignore - -create or replace function count_operator(explain_query text, operator text) returns int as -$$ -rv = plpy.execute(explain_query) -search_text = operator -result = 0 -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = result+1 -return result -$$ -language plpythonu; - -create or replace function find_operator(query text, operator_name text) returns text as -$$ -rv = plpy.execute(query) -search_text = operator_name -result = ['false'] -for i in range(len(rv)): - cur_line = rv[i]['QUERY PLAN'] - if search_text.lower() in cur_line.lower(): - result = ['true'] - break -return result -$$ -language plpythonu; - ---- ---- Tests if it produces SIGSEGV from "select from partition_table group by rollup or cube function" ---- - --- SETUP --- start_ignore -drop table if exists mpp7980; --- end_ignore -create table mpp7980 -( - month_id date, - bill_stmt_id character varying(30), - cust_type character varying(10), - subscription_status character varying(30), - voice_call_min numeric(15,2), - minute_per_call numeric(15,2), - subscription_id character varying(15) -) -distributed by (subscription_id, bill_stmt_id) - PARTITION BY RANGE(month_id) - ( - start ('2009-02-01'::date) end ('2009-08-01'::date) exclusive EVERY (INTERVAL '1 month') - ); - --- TEST -select count_operator('explain select cust_type, subscription_status,count(distinct subscription_id),sum(voice_call_min),sum(minute_per_call) from mpp7980 where month_id =\'2009-04-01\' group by rollup(1,2);','SIGSEGV'); - --- CLEANUP --- start_ignore -drop table mpp7980; --- end_ignore - - - ---- ---- Tests if it is using casting comparator for partition selector with compatible types ---- - --- SETUP -CREATE TABLE TIMESTAMP_MONTH_rangep_STARTINCL (i1 int, f2 timestamp) -partition by range (f2) -( - start ('2000-01-01'::timestamp) INCLUSIVE - end (date '2001-01-01'::timestamp) EXCLUSIVE - every ('1 month'::interval) -); - -CREATE TABLE TIMESTAMP_MONTH_rangep_STARTEXCL (i1 int, f2 timestamp) -partition by range (f2) -( - start ('2000-01-01'::timestamp) EXCLUSIVE - end (date '2001-01-01'::timestamp) INCLUSIVE - every ('1 month'::interval) -); - -CREATE TABLE TIMESTAMP_MONTH_listp (i1 int, f2 timestamp) -partition by list (f2) -( - partition jan1 values ('2000-01-01'::timestamp), - partition jan2 values ('2000-01-02'::timestamp), - partition jan3 values ('2000-01-03'::timestamp), - partition jan4 values ('2000-01-04'::timestamp), - partition jan5 values ('2000-01-05'::timestamp) -); - - --- TEST --- Middle of a middle range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (1, '2000-07-16'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-07-16'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-07-16', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-07-16', 'YYYY-MM-DD'); - --- Beginning of the first range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (2, '2000-01-01'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-01-01'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-01-01', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-01-01', 'YYYY-MM-DD'); - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (3, '2000-01-02'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-01-02'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-01-02', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-01-02', 'YYYY-MM-DD'); - --- End of the last range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (4, '2000-12-31'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2000-12-31'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2000-12-31', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2000-12-31', 'YYYY-MM-DD'); - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTINCL values (5, '2001-01-01'); -- should fail, no such partition -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = '2001-01-01'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_TIMESTAMP('2001-01-01', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTINCL WHERE f2 = TO_DATE('2001-01-01', 'YYYY-MM-DD'); - --- Range partitioning: START EXCLUSIVE, END INCLUSIVE --- Middle of a middle range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (1, '2000-07-16'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-07-16'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-07-16', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-07-16', 'YYYY-MM-DD'); - --- Beginning of the first range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (2, '2000-01-01'); -- should fail, no such partition -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-01-01'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-01-01', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-01-01', 'YYYY-MM-DD'); - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (3, '2000-01-02'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-01-02'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-01-02', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-01-02', 'YYYY-MM-DD'); - --- End of the last range -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (4, '2000-12-31'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2000-12-31'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2000-12-31', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2000-12-31', 'YYYY-MM-DD'); - -INSERT INTO TIMESTAMP_MONTH_rangep_STARTEXCL values (5, '2001-01-01'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = '2001-01-01'; -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_TIMESTAMP('2001-01-01', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_rangep_STARTEXCL WHERE f2 = TO_DATE('2001-01-01', 'YYYY-MM-DD'); - - --- List partitioning -INSERT INTO TIMESTAMP_MONTH_listp values (1, '2000-01-03'); -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = '2000-01-03'; -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = TO_TIMESTAMP('2000-01-03', 'YYYY-MM-DD'); -SELECT * FROM TIMESTAMP_MONTH_listp WHERE f2 = TO_DATE('2000-01-03', 'YYYY-MM-DD'); - --- CLEANUP --- start_ignore -DROP TABLE TIMESTAMP_MONTH_listp; -DROP TABLE TIMESTAMP_MONTH_rangep_STARTEXCL; -DROP TABLE TIMESTAMP_MONTH_rangep_STARTINCL; --- end_ignore - - ---- ---- Data Engineer can see partition key in psql ---- - --- SETUP --- start_ignore -DROP TABLE IF EXISTS T26002_T1; -DROP TABLE IF EXISTS T26002_T2; --- end_ignore - -CREATE TABLE T26002_T1 (empid int, departmentid int, year int, region varchar(20)) -DISTRIBUTED BY (empid) - PARTITION BY RANGE (year) - SUBPARTITION BY LIST (region, departmentid) - SUBPARTITION TEMPLATE ( - SUBPARTITION usa VALUES (('usa', 1)), - SUBPARTITION europe VALUES (('europe', 2)), - SUBPARTITION asia VALUES (('asia', 3)), - DEFAULT SUBPARTITION other_regions) -( START (2012) END (2015) EVERY (3), - DEFAULT PARTITION outlying_years); - --- TEST --- expected to see the partition key -\d T26002_T1; -\d t26002_t1_1_prt_2; -\d t26002_t1_1_prt_2_2_prt_asia; - -\d+ T26002_T1; -\d+ t26002_t1_1_prt_2; -\d+ t26002_t1_1_prt_2_2_prt_asia; - -/* --- test 2: Data Engineer won't see partition key for non-partitioned table -GIVEN I am a Data Engineer -WHEN I run \d on a non-partitioned table -THEN I should NOT see the partition key in the output -*/ -CREATE TABLE T26002_T2 (empid int, departmentid int, year int, region varchar(20)) -DISTRIBUTED BY (empid); - -\d T26002_T2; - -\d+ T26002_T2; - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS T26002_T1; -DROP TABLE IF EXISTS T26002_T2; --- end_ignore - - - - - - - --- ************ORCA ENABLED********** - - --- --- MPP-23195 --- - --- SETUP --- start_ignore -set optimizer_enable_bitmapscan=on; -set optimizer_enable_indexjoin=on; -drop table if exists mpp23195_t1; -drop table if exists mpp23195_t2; --- end_ignore - -create table mpp23195_t1 (i int) partition by range(i) (partition pt1 start(1) end(10), partition pt2 start(10) end(20)); -create index index_mpp23195_t1_i on mpp23195_t1(i); -create table mpp23195_t2(i int); - -insert into mpp23195_t1 values (generate_series(1,19)); -insert into mpp23195_t2 values (1); - --- TEST -select find_operator('explain select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i;', 'Dynamic Index Scan'); -select * from mpp23195_t1,mpp23195_t2 where mpp23195_t1.i < mpp23195_t2.i; - --- CLEANUP --- start_ignore -drop table if exists mpp23195_t1; -drop table if exists mpp23195_t2; -set optimizer_enable_bitmapscan=off; -set optimizer_enable_indexjoin=off; --- end_ignore - - ---- ---- Check we have Dynamic Index Scan operator and check we have Nest loop operator ---- - --- SETUP --- start_ignore -drop table if exists mpp21834_t1; -drop table if exists mpp21834_t2; --- end_ignore - -create table mpp21834_t1 (i int, j int) partition by range(i) (partition pp1 start(1) end(10), partition pp2 start(10) end(20)); - -create index index_1 on mpp21834_t1(i); - -create index index_2 on mpp21834_t1(j); - -create table mpp21834_t2(i int, j int); - --- TEST --- start_ignore -select disable_xform('CXformInnerJoin2HashJoin'); --- end_ignore -select find_operator('explain analyze select * from mpp21834_t2,mpp21834_t1 where mpp21834_t2.i < mpp21834_t1.i;','Dynamic Index Scan'); -select find_operator('explain analyze select * from mpp21834_t2,mpp21834_t1 where mpp21834_t2.i < mpp21834_t1.i;','Nested Loop'); - --- CLEANUP --- start_ignore -drop index index_2; -drop index index_1; -drop table if exists mpp21834_t2; -drop table if exists mpp21834_t1; -select enable_xform('CXformInnerJoin2HashJoin'); --- end_ignore - - ---- ---- A rescanning of DTS with its own partition selector (under sequence node) ---- - --- SETUP --- start_ignore -set optimizer_enable_broadcast_nestloop_outer_child=on; -drop table if exists mpp23288; --- end_ignore - -create table mpp23288(a int, b int) - partition by range (a) - ( - PARTITION pfirst END(5) INCLUSIVE, - PARTITION pinter START(5) EXCLUSIVE END (10) INCLUSIVE, - PARTITION plast START (10) EXCLUSIVE - ); - -insert into mpp23288(a) select generate_series(1,20); - -analyze mpp23288; - --- TEST -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and t2.a =10) order by t2.a, t1.a;','Dynamic Table Scan'); -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and t2.a =10) order by t2.a, t1.a; - -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and (t2.a = 10 or t2.a = 5 or t2.a = 12)) order by t2.a, t1.a;','Dynamic Table Scan'); -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on (t1.a < t2.a and (t2.a = 10 or t2.a = 5 or t2.a = 12)) order by t2.a, t1.a; - -select count_operator('explain select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on t1.a < t2.a and t2.a = 1 or t2.a < 10 order by t2.a, t1.a;','Dynamic Table Scan'); -select t2.a, t1.a from mpp23288 as t1 join mpp23288 as t2 on t1.a < t2.a and t2.a = 1 or t2.a < 10 order by t2.a, t1.a; - --- CLEANUP --- start_ignore -drop table if exists mpp23288; -set optimizer_enable_broadcast_nestloop_outer_child=off; --- end_ignore - - ---- ---- Testing whether test gives wrong results with partition tables when sub-partitions are distributed differently than the parent partition. ---- - --- SETUP --- start_ignore -drop table if exists pt; -drop table if exists t; --- end_ignore - -create table pt(a int, b int, c int) distributed by (a) partition by range(b) (start(0) end(10) every (2)); -alter table pt_1_prt_1 set distributed randomly; - -create table t(a int, b int); -insert into pt select g%10, g%2 + 1, g*2 from generate_series(1,20) g; -insert into pt values(1,1,3); -insert into t select g%10, g%2 + 1 from generate_series(1,20) g; - -create index pt_c on pt(c); - -analyze t; -analyze pt; - --- TEST -SELECT COUNT(*) FROM pt, t WHERE pt.a = t.a; -SELECT COUNT(*) FROM pt, t WHERE pt.a = t.a and pt.c=4; - -select a, count(*) from pt group by a; -select b, count(*) from pt group by b; -select a, count(*) from pt where a<2 group by a; - --- CLEANUP --- start_ignore -drop index pt_c; -drop table if exists pt; -drop table if exists t; --- end_ignore - - ---- ---- Tests if DynamicIndexScan sets tuple descriptor of the planstate->ps_ResultTupleSlot ---- - --- SETUP --- start_ignore -drop table if exists mpp24151_t; -drop table if exists mpp24151_pt; --- end_ignore - -create table mpp24151_t(dist int, tid int, t1 text, t2 text); -create table mpp24151_pt(dist int, pt1 text, pt2 text, pt3 text, ptid int) -DISTRIBUTED BY (dist) -PARTITION BY RANGE(ptid) - ( - START (0) END (5) EVERY (1), - DEFAULT PARTITION junk_data - ) -; -create index pt1_idx on mpp24151_pt using btree (pt1); -create index ptid_idx on mpp24151_pt using btree (ptid); -insert into mpp24151_pt select i, 'hello' || 0, 'world', 'drop this', i % 6 from generate_series(0,100)i; -insert into mpp24151_pt select i, 'hello' || i, 'world', 'drop this', i % 6 from generate_series(0,200000)i; - -insert into mpp24151_t select i, i % 6, 'hello' || i, 'bar' from generate_series(0,10)i; -analyze mpp24151_pt; -analyze mpp24151_t; - --- TEST --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan'); --- end_ignore - -select count_operator('explain select * from mpp24151_t, mpp24151_pt where tid = ptid and pt1 = \'hello0\';','Result'); -select * from mpp24151_t, mpp24151_pt where tid = ptid and pt1 = 'hello0'; - --- CLEANUP --- start_ignore -drop index ptid_idx; -drop index pt1_idx; -drop table if exists mpp24151_t; -drop table if exists mpp24151_pt; -select enable_xform('CXformDynamicGet2DynamicTableScan'); --- end_ignore - - ---- ---- No DPE (Dynamic Partition Elimination) on second child of a union under a join ---- - --- SETUP --- start_ignore -drop table if exists t; -drop table if exists p1; -drop table if exists p2; -drop table if exists p3; -drop table if exists p; --- end_ignore - -create table p1 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -create table p2 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -create table p3 (a int, b int) partition by range(b) (start (1) end(100) every (20)); -create table p (a int, b int); -create table t(a int, b int); - -insert into t select g, g*10 from generate_series(1,100) g; - -insert into p1 select g, g%99 +1 from generate_series(1,10000) g; - -insert into p2 select g, g%99 +1 from generate_series(1,10000) g; - -insert into p3 select g, g%99 +1 from generate_series(1,10000) g; - -insert into p select g, g%99 +1 from generate_series(1,10000) g; - -analyze t; -analyze p1; -analyze p2; -analyze p3; -analyze p; - --- TEST -select count_operator('explain select * from (select * from p1 union all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 union select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 except all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 except select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 intersect all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 union select * from p2 union all select * from p3) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 union select * from p2 union all select * from p) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 union select * from p union all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 union select * from p2 intersect all select * from p3) as p_all, t where p_all.b=t.b;','Partition Selector'); - -select count_operator('explain select * from (select * from p1 union select * from p intersect all select * from p2) as p_all, t where p_all.b=t.b;','Partition Selector'); - --- CLEANUP --- start_ignore -drop table t; -drop table p1; -drop table p2; -drop table p3; -drop table p; --- end_ignore - - ---- ---- Gracefully handle NULL partition set from BitmapTableScan, DynamicTableScan and DynamicIndexScan ---- - --- SETUP --- start_ignore -drop table if exists dts; -drop table if exists dis; -drop table if exists dbs; --- end_ignore - -create table dts(c1 int, c2 int) partition by range(c2) (start(1) end(11) every(1)); -create table dis(c1 int, c2 int, c3 int) partition by range(c2) (start(1) end(11) every(1)); -create index dis_index on dis(c3); -CREATE TABLE dbs(c1 int, c2 int, c3 int) partition by range(c2) (start(1) end(11) every(1)); -create index dbs_index on dbs using bitmap(c3); - - --- TEST -select find_operator('explain (select * from dts where c2 = 1) union (select * from dts where c2 = 2) union (select * from dts where c2 = 3) union (select * from dts where c2 = 4) union (select * from dts where c2 = 5) union (select * from dts where c2 = 6) union (select * from dts where c2 = 7) union (select * from dts where c2 = 8) union (select * from dts where c2 = 9) union (select * from dts where c2 = 10);', 'Dynamic Table Scan'); - -(select * from dts where c2 = 1) union -(select * from dts where c2 = 2) union -(select * from dts where c2 = 3) union -(select * from dts where c2 = 4) union -(select * from dts where c2 = 5) union -(select * from dts where c2 = 6) union -(select * from dts where c2 = 7) union -(select * from dts where c2 = 8) union -(select * from dts where c2 = 9) union -(select * from dts where c2 = 10); - --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan'); --- end_ignore - -select find_operator('explain (select * from dis where c3 = 1) union (select * from dis where c3 = 2) union (select * from dis where c3 = 3) union (select * from dis where c3 = 4) union (select * from dis where c3 = 5) union (select * from dis where c3 = 6) union (select * from dis where c3 = 7) union (select * from dis where c3 = 8) union (select * from dis where c3 = 9) union (select * from dis where c3 = 10);', 'Dynamic Index Scan'); - -(select * from dis where c3 = 1) union -(select * from dis where c3 = 2) union -(select * from dis where c3 = 3) union -(select * from dis where c3 = 4) union -(select * from dis where c3 = 5) union -(select * from dis where c3 = 6) union -(select * from dis where c3 = 7) union -(select * from dis where c3 = 8) union -(select * from dis where c3 = 9) union -(select * from dis where c3 = 10); - -select find_operator('explain select * from dbs where c2= 15 and c3 = 5;', 'Bitmap Table Scan'); - -select * from dbs where c2= 15 and c3 = 5; - --- CLEANUP --- start_ignore -drop index dbs_index; -drop table if exists dbs; -drop index dis_index; -drop table if exists dis; -drop table if exists dts; -select enable_xform('CXformDynamicGet2DynamicTableScan'); --- end_ignore - ---- ---- Partition elimination for heterogenous DynamicIndexScans ---- - --- SETUP --- start_ignore -drop table if exists pp; -drop index if exists pp_1_prt_1_idx; -drop index if exists pp_rest_1_idx; -drop index if exists pp_rest_2_idx; -set optimizer_segments=2; -set optimizer_partition_selection_log=on; --- end_ignore -create table pp(a int, b int, c int) partition by range(b) (start(1) end(15) every(5)); -insert into pp values (1,1,2),(2,6,2), (3,11,2); --- Heterogeneous Index on the partition table -create index pp_1_prt_1_idx on pp_1_prt_1(c); --- Create other indexes so that we can automate the repro for MPP-21069 by disabling tablescan -create index pp_rest_1_idx on pp_1_prt_2(c,a); -create index pp_rest_2_idx on pp_1_prt_3(c,a); --- TEST --- start_ignore -select disable_xform('CXformDynamicGet2DynamicTableScan') ; --- end_ignore - -select * from pp where b=2 and c=2; -select count_operator('explain select * from pp where b=2 and c=2;','Partition Selector'); - --- CLEANUP --- start_ignore -drop index if exists pp_rest_2_idx; -drop index if exists pp_rest_1_idx; -drop index if exists pp_1_prt_1_idx; -drop table if exists pp; -select enable_xform('CXformDynamicGet2DynamicTableScan') ; -reset optimizer_segments; -set optimizer_partition_selection_log=off; -select enable_xform('CXformDynamicGet2DynamicTableScan') ; --- end_ignore - - ---- ---- Partition elimination with implicit CAST on the partitioning key ---- - --- SETUP --- start_ignore -set optimizer_segments=2; -set optimizer_partition_selection_log=on; -DROP TABLE IF EXISTS ds_4; --- end_ignore - -CREATE TABLE ds_4 -( - month_id character varying(6), - cust_group_acc numeric(10), - mobile_no character varying(10) -) -DISTRIBUTED BY (cust_group_acc, mobile_no) -PARTITION BY LIST(month_id) - ( - PARTITION p200800 VALUES('200800'), - PARTITION p200801 VALUES('200801'), - PARTITION p200802 VALUES('200802'), - PARTITION p200803 VALUES('200803') -); - --- TEST -select * from ds_4 where month_id = '200800'; -select count_operator('explain select * from ds_4 where month_id = \'200800\';','Partition Selector'); - -select * from ds_4 where month_id > '200800'; -select count_operator('explain select * from ds_4 where month_id > \'200800\';','Partition Selector'); - -select * from ds_4 where month_id <= '200800'; -select count_operator('explain select * from ds_4 where month_id <= \'200800\';','Partition Selector'); - -select * from ds_4 a1,ds_4 a2 where a1.month_id = a2.month_id and a1.month_id > '200800'; -select count_operator('explain select * from ds_4 a1,ds_4 a2 where a1.month_id = a2.month_id and a1.month_id > \'200800\';','Partition Selector'); - --- CLEANUP --- start_ignore -DROP TABLE IF EXISTS ds_4; -set optimizer_partition_selection_log=off; -reset optimizer_segments; - -drop function if exists find_operator(query text, operator_name text); -drop function if exists count_operator(query text, operator_name text); -drop language if exists plpythonu; --- end_ignore