提交 89c3ea4f 编写于 作者: H Heikki Linnakangas

Remove unnecessary DROP commands from test file.

The test runs in a schema of its own, bfv_aggregate. It is created at
the beginning of the test, so we can safely assume that it's empty.
Also, rather than dropping created objects after each test, just drop
the whole schema at the end.
上级 850baebb
......@@ -4,12 +4,6 @@ set search_path=bfv_aggregate;
--- 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.
......@@ -88,11 +82,6 @@ select * from x_outer where a in (select last_value(d) over(partition by b order
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
---
......@@ -108,22 +97,10 @@ select 1, to_char(col1, 'YYYY'), median(col2) from d group by 1, 2;
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.
......@@ -138,12 +115,6 @@ select
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
---
......@@ -180,15 +151,6 @@ select f3, array_sort(myaggp20a(f1)) from t group by f3 order by f3;
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
create language plpythonu;
-- end_ignore
......@@ -208,29 +170,21 @@ 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
----------------
......@@ -238,20 +192,13 @@ select count_operator('explain select count(*) from multi_stage_test group by b;
(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)
......@@ -264,10 +211,6 @@ ELSE $1 || $2 END;'
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
......@@ -276,9 +219,7 @@ CREATE AGGREGATE concat(text) (
);
-- 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
......@@ -287,20 +228,11 @@ select count_operator('explain select product_id,concat(E''#attribute_''||attrib
(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');
......@@ -1538,10 +1470,5 @@ from mtup1 where c0 = 'foo' group by c0, c1 limit 10;
(1 row)
-- 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 schema if exists bfv_aggregate;
-- end_ignore
set client_min_messages='warning';
drop schema bfv_aggregate cascade;
......@@ -4,12 +4,6 @@ set search_path=bfv_aggregate;
--- 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.
......@@ -88,11 +82,6 @@ select * from x_outer where a in (select last_value(d) over(partition by b order
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
---
......@@ -108,22 +97,10 @@ select 1, to_char(col1, 'YYYY'), median(col2) from d group by 1, 2;
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);
......@@ -137,12 +114,6 @@ select
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
---
......@@ -179,15 +150,6 @@ select f3, array_sort(myaggp20a(f1)) from t group by f3 order by f3;
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
create language plpythonu;
-- end_ignore
......@@ -207,29 +169,21 @@ 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
----------------
......@@ -237,20 +191,13 @@ select count_operator('explain select count(*) from multi_stage_test group by b;
(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)
......@@ -263,10 +210,6 @@ ELSE $1 || $2 END;'
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
......@@ -275,9 +218,7 @@ CREATE AGGREGATE concat(text) (
);
-- 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
......@@ -286,20 +227,11 @@ select count_operator('explain select product_id,concat(E''#attribute_''||attrib
(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');
......@@ -1537,10 +1469,5 @@ from mtup1 where c0 = 'foo' group by c0, c1 limit 10;
(1 row)
-- 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 schema if exists bfv_aggregate;
-- end_ignore
set client_min_messages='warning';
drop schema bfv_aggregate cascade;
......@@ -6,10 +6,6 @@ set search_path=bfv_aggregate;
---
-- 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;
......@@ -30,12 +26,6 @@ select * from x_outer where not exists (select rank() over(order by a) from y_in
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
---
......@@ -47,21 +37,11 @@ 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);
......@@ -75,13 +55,6 @@ select
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
---
......@@ -117,15 +90,6 @@ 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
create language plpythonu;
-- end_ignore
......@@ -147,40 +111,28 @@ language plpythonu;
---
-- 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)
......@@ -193,9 +145,6 @@ ELSE $1 || $2 END;'
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
......@@ -205,19 +154,12 @@ CREATE AGGREGATE concat(text) (
-- 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
---
......@@ -225,9 +167,6 @@ SET optimizer_disable_missing_stats_collection=off;
---
-- SETUP
-- start_ignore
DROP TABLE IF EXISTS foo;
-- end_ignore
create table foo(a int, b text) distributed by (a);
-- TEST
......@@ -1417,9 +1356,5 @@ from mtup1 where c0 = 'foo' group by c0, c1 limit 10;
-- 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 schema if exists bfv_aggregate;
-- end_ignore
set client_min_messages='warning';
drop schema bfv_aggregate cascade;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册