提交 e486aa03 编写于 作者: H Heikki Linnakangas

Move test case on gp_create_table_random_default_distribution from TINC.

These tests were almost redundant with existing tests, but there were
a couple of things they did test:

* gp_create_table_random_default_distribution = on works, and
* you cannot add a PRIMARY KEY to a randomly distributed table.
上级 b44d6955
--MPP-22020: Dis-allow duplicate constraint names for the same table.
create table dupconstr (
i int,
i int,
j int constraint test CHECK (j > 10),
CONSTRAINT test UNIQUE (i,j))
distributed by (i);
......@@ -89,6 +89,34 @@ ERROR: UNIQUE index must contain all columns in the distribution key of relatio
alter table distpol add primary key (i);
ERROR: PRIMARY KEY must contain all columns in the distribution key of relation "distpol"
drop table distpol;
-- Make sure that distribution policy is derived correctly from PRIMARY KEY
-- or UNIQUE index. Even with gp_create_table_random_default_distribution=on
SET gp_create_table_random_default_distribution=on;
create table distpol_no_pk (i int, j int, k int);
NOTICE: Using default RANDOM distribution since no distribution was specified.
HINT: Consider including the 'DISTRIBUTED BY' clause to determine the distribution of rows.
create table distpol_with_pk (i int, j int, k int, PRIMARY KEY (i));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "distpol_with_pk_pkey" for table "distpol_with_pk"
create table distpol_with_unique (i int, j int, k int, CONSTRAINT uconn UNIQUE (i, j));
NOTICE: CREATE TABLE / UNIQUE will create implicit index "distpol_with_unique_i_key" for table "distpol_with_unique"
select localoid::regclass, attrnums from gp_distribution_policy where
localoid IN ('distpol_no_pk'::regclass,
'distpol_with_pk'::regclass,
'distpol_with_unique'::regclass);
localoid | attrnums
---------------------+----------
distpol_no_pk |
distpol_with_pk | {1}
distpol_with_unique | {1,2}
(3 rows)
-- If a table is previously DISTRIBUTED RANDOMLY, you cannot add a primary key
-- to it. (If it's previously distributed by another column, then you can add
-- a primary key to it, but it will implicitly re-distribute it by the primary
-- key column. That case is tested above already.)
alter table distpol_no_pk add primary key (i);
ERROR: PRIMARY KEY and DISTRIBUTED RANDOMLY are incompatible
RESET gp_create_table_random_default_distribution;
-- MPP-2872: set ops with distributed by should work as advertised
create table distpol1 (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.
......@@ -166,7 +194,7 @@ create table foo (a int, b int) distributed by (c,C);
ERROR: column "c" named in 'DISTRIBUTED BY' clause does not exist
create table foo ("I" int, i int) distributed by ("I",I);
select attrnums from gp_distribution_policy where localoid='foo'::regclass;
attrnums
attrnums
----------
{1,2}
(1 row)
......
......@@ -55,6 +55,27 @@ create unique index distpol_uidx on distpol(i);
alter table distpol add primary key (i);
drop table distpol;
-- Make sure that distribution policy is derived correctly from PRIMARY KEY
-- or UNIQUE index. Even with gp_create_table_random_default_distribution=on
SET gp_create_table_random_default_distribution=on;
create table distpol_no_pk (i int, j int, k int);
create table distpol_with_pk (i int, j int, k int, PRIMARY KEY (i));
create table distpol_with_unique (i int, j int, k int, CONSTRAINT uconn UNIQUE (i, j));
select localoid::regclass, attrnums from gp_distribution_policy where
localoid IN ('distpol_no_pk'::regclass,
'distpol_with_pk'::regclass,
'distpol_with_unique'::regclass);
-- If a table is previously DISTRIBUTED RANDOMLY, you cannot add a primary key
-- to it. (If it's previously distributed by another column, then you can add
-- a primary key to it, but it will implicitly re-distribute it by the primary
-- key column. That case is tested above already.)
alter table distpol_no_pk add primary key (i);
RESET gp_create_table_random_default_distribution;
-- MPP-2872: set ops with distributed by should work as advertised
create table distpol1 (i int, j int);
create table distpol2 (i int, j int);
......
-- start_ignore
SET gp_create_table_random_default_distribution=on;
SET
SET optimizer=off;
SET
-- end_ignore
-- PRIMARY KEY default behavior
select attrnums from gp_distribution_policy where
localoid = 'distpol'::regclass;
attrnums
----------
{1}
(1 row)
alter table dist add primary key (j);
psql:/Users/garcic12/dev/tincrepo/private/QP-private/ddl/default_distribution/out/create_table_primary_key.sql:10: ERROR: PRIMARY KEY and DISTRIBUTED RANDOMLY are incompatible
-- start_ignore
SET gp_create_table_random_default_distribution=on;
SET
SET optimizer=off;
SET
-- end_ignore
-- UNIQUE default behavior
DROP TABLE IF EXISTS dupconstr;
psql:/Users/garcic12/dev/tincrepo/private/QP-private/ddl/default_distribution/out/create_table_unique_planner.sql:8: NOTICE: table "dupconstr" does not exist, skipping
DROP TABLE
create table dupconstr (
i int,
j int constraint test CHECK (j > 10),
CONSTRAINT test1 UNIQUE (i,j));
psql:/Users/garcic12/dev/tincrepo/private/QP-private/ddl/default_distribution/out/create_table_unique_planner.sql:12: NOTICE: CREATE TABLE / UNIQUE will create implicit index "dupconstr_i_key" for table "dupconstr"
CREATE TABLE
-- UNIQUE default behavior
create unique index distpol_uidx on distpol(c1);
CREATE INDEX
-- start_ignore
SET gp_create_table_random_default_distribution=off;
SET
SET optimizer=off;
SET
-- end_ignore
-- @author onosen
-- @created 2014-07-01 18:09:00
-- @tags ORCA
-- @optimizer_mode off
-- @gucs gp_create_table_random_default_distribution=on
-- @product_version gpdb: [4.3-]
-- @description test CREATE TABLE with default distribution set to random
select attrnums from gp_distribution_policy where
localoid = 'hobbies_r'::regclass;
attrnums
----------
{1}
(1 row)
select attrnums from gp_distribution_policy where
localoid = 'tenk1'::regclass;
attrnums
----------
{1}
(1 row)
-- start_ignore
SET gp_create_table_random_default_distribution=on;
SET
SET optimizer=off;
SET
-- end_ignore
-- @author onosen
-- @created 2014-07-01 18:09:00
-- @tags ORCA
-- @optimizer_mode off
-- @gucs gp_create_table_random_default_distribution=on
-- @product_version gpdb: [4.3-]
-- @description test CREATE TABLE with default distribution set to random
select attrnums from gp_distribution_policy where
localoid = 'hobbies_r'::regclass;
attrnums
----------
(1 row)
select attrnums from gp_distribution_policy where
localoid = 'tenk1'::regclass;
attrnums
----------
(1 row)
select attrnums from gp_distribution_policy where
localoid = 'hobbies_r'::regclass;
select attrnums from gp_distribution_policy where
localoid = 'tenk1'::regclass;
DROP TABLE IF EXISTS hobbies_r;
CREATE TABLE hobbies_r (
name text,
person text
);
DROP TABLE IF EXISTS tenk1;
CREATE TABLE tenk1 (
unique1 int4,
unique2 int4,
two int4,
four int4,
ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
) WITH OIDS;
-- PRIMARY KEY default behavior
select attrnums from gp_distribution_policy where
localoid = 'distpol'::regclass;
alter table dist add primary key (j);
drop table if exists distpol;
create table distpol (i int, j int, k int, PRIMARY KEY (i));
drop table if exists dist;
create table dist (i int, j int, k int);
-- UNIQUE default behavior
DROP TABLE IF EXISTS dupconstr;
create table dupconstr (
i int,
j int constraint test CHECK (j > 10),
CONSTRAINT test1 UNIQUE (i,j));
-- UNIQUE default behavior
create unique index distpol_uidx on distpol(c1);
drop table if exists distpol;
create table distpol(c1 int, c2 text) distributed by (c1);
......@@ -15,53 +15,3 @@ class test_create_table_default_distribution(SQLTestCase):
sql_dir = 'sql/'
ans_dir = 'expected/'
out_dir = 'out/'
class test_create_table_default_distribution_GPDB(SQLTestCase):
'''
testing CREATE TABLE with default distribution
@author garcic12
@created 2014-07-01 18:09:00
@description test CREATE TABLE with default distribution
@gpopt 1.510
@gucs gp_create_table_random_default_distribution=on
@tags CTAS ORCA
@product_version gpdb: 4.3.99.99, [4.3-], 4.3.2.0ORCA1
'''
sql_dir = 'sql_gpdb/'
ans_dir = 'expected/'
out_dir = 'out/'
class test_create_table_default_distribution_On(SQLTestCase):
'''
testing CREATE TABLE with default distribution
@author garcic12
@created 2014-07-01 18:09:00
@tags CTAS HAWQ ORCA
@product_version gpdb: 4.3.99.99, [4.3-], 4.3.2.0ORCA1, hawq: [1.3-]
@description test CREATE TABLE with default distribution
@gpopt 1.510
@gucs gp_create_table_random_default_distribution=on
'''
sql_dir = 'sql_default_distribution_sensitive/'
ans_dir = 'expected_default_distribution_On/'
out_dir = 'out/'
class test_create_table_default_distribution_Off(SQLTestCase):
'''
testing CREATE TABLE with default distribution
@author garcic12
@created 2014-07-01 18:09:00
@description test CREATE TABLE with default distribution
@gpopt 1.510
@gucs gp_create_table_random_default_distribution=off
@tags CTAS HAWQ ORCA
@product_version gpdb: 4.3.99.99, [4.3-], 4.3.2.0ORCA1, hawq: [1.3-]
'''
sql_dir = 'sql_default_distribution_sensitive/'
ans_dir = 'expected_default_distribution_Off/'
out_dir = 'out/'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册