From 74059ccaf887e50f0f5a7faf1ace557d7c503a30 Mon Sep 17 00:00:00 2001 From: Shaoqi Bai Date: Fri, 25 Jan 2019 09:22:45 +0800 Subject: [PATCH] Disallow alter parition table's leaf with different distribution compared with entire partitioned table. (#6780) Reviewed-by: Heikki Linnakangas Reviewed-by: Daniel Gustafsson --- src/backend/commands/tablecmds.c | 44 ++------- .../expected/alter_distribution_policy.out | 68 -------------- src/test/regress/expected/bfv_partition.out | 2 + src/test/regress/expected/direct_dispatch.out | 11 +-- .../expected/direct_dispatch_optimizer.out | 4 +- src/test/regress/expected/gpdist.out | 16 ++-- .../regress/expected/gpdist_optimizer.out | 16 ++-- src/test/regress/expected/metadata_track.out | 4 + src/test/regress/input/gpcopy.source | 7 -- src/test/regress/output/gpcopy.source | 7 -- .../regress/sql/alter_distribution_policy.sql | 89 ------------------- src/test/regress/sql/gpdist.sql | 2 +- 12 files changed, 38 insertions(+), 232 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 14feb1cc92..c54cbdc4ef 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -4611,16 +4611,15 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, { case PART_STATUS_NONE: case PART_STATUS_ROOT: - case PART_STATUS_LEAF: break; - + case PART_STATUS_LEAF: case PART_STATUS_INTERIOR: /*Reject interior branches of partitioned tables.*/ ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("can't set the distribution policy of \"%s\"", RelationGetRelationName(rel)), - errhint("Distribution policy may be set for an entire partitioned table or one of its leaf parts; not for an interior branch."))); + errhint("Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch."))); break; /* tidy */ } } @@ -4629,51 +4628,18 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, switch (ps) { case PART_STATUS_NONE: - case PART_STATUS_LEAF: break; - + case PART_STATUS_LEAF: case PART_STATUS_ROOT: case PART_STATUS_INTERIOR: ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("can't set the distribution policy " - "of ONLY \"%s\"", + errmsg("can't set the distribution policy of ONLY \"%s\"", RelationGetRelationName(rel)), - errhint("Distribution policy may be set " - "for an entire partitioned table" - " or one of its leaf parts." - ))); + errhint("Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch."))); break; /* tidy */ } } - - if ( ps == PART_STATUS_LEAF ) - { - Oid ptrelid = rel_partition_get_master(relid); - DistributedBy *dist = lsecond((List*)cmd->def); - - /* might be null if no policy set, e.g. just - * a change of storage options... - */ - if (dist) - { - Relation ptrel = heap_open(ptrelid, - AccessShareLock); - Assert(IsA(dist, DistributedBy)); - - if (! can_implement_dist_on_part(ptrel, - dist) ) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot SET DISTRIBUTED BY for %s", - RelationGetRelationName(rel)), - errhint("Leaf distribution policy must be" - " random or match that of the" - " entire partitioned table.") - )); - heap_close(ptrel, AccessShareLock); - } - } } ATSimplePermissions(rel, ATT_TABLE); diff --git a/src/test/regress/expected/alter_distribution_policy.out b/src/test/regress/expected/alter_distribution_policy.out index e427e03eae..7463693805 100644 --- a/src/test/regress/expected/alter_distribution_policy.out +++ b/src/test/regress/expected/alter_distribution_policy.out @@ -159,47 +159,6 @@ select count(*) from atsdb_ao; (1 row) drop table atsdb_ao; --- Check divergent distribution policies for partitioning. -create table atsdb (i int, j int, k int) distributed by (i) partition by range(k) -(start(1) end(4) every(1)); -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 "atsdb_1_prt_1" for table "atsdb" -NOTICE: CREATE TABLE will create partition "atsdb_1_prt_2" for table "atsdb" -NOTICE: CREATE TABLE will create partition "atsdb_1_prt_3" for table "atsdb" -alter table atsdb_1_prt_2 set distributed by (j); -ERROR: cannot SET DISTRIBUTED BY for atsdb_1_prt_2 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. -alter table atsdb_1_prt_3 set distributed randomly; --- test COPY -copy atsdb from stdin delimiter '|'; -select count(*) from atsdb; - count -------- - 18 -(1 row) - --- compare distribution: we create a table, identical to the partitioned table, --- and compare how the tuples have been distributed. -create table atsdb_1 (like atsdb_1_prt_1) distributed by (i); -copy atsdb_1 from stdin delimiter '|'; -select gp_segment_id, * from atsdb where k = 1 except -select gp_segment_id, * from atsdb_1; - gp_segment_id | i | j | k ----------------+---+---+--- -(0 rows) - -create table atsdb_2 (like atsdb_1_prt_2) distributed by (i); -copy atsdb_2 from stdin delimiter '|'; -select gp_segment_id, * from atsdb where k = 2 except -select gp_segment_id, * from atsdb_2; - gp_segment_id | i | j | k ----------------+---+---+--- -(0 rows) - --- Can't test randomly distributed --- Can't test INSERT (yet) -drop table atsdb, atsdb_1, atsdb_2; -- Can't redistribute system catalogs alter table pg_class set distributed by (relname); ERROR: permission denied: "pg_class" is a system catalog @@ -1386,33 +1345,6 @@ HINT: the DISTRIBUTED BY columns must be a subset of the UNIQUE INDEX columns. ALTER TABLE t_dist2 SET DISTRIBUTED BY(col4); ERROR: UNIQUE INDEX and DISTRIBUTED BY definitions incompatible HINT: the DISTRIBUTED BY columns must be a subset of the UNIQUE INDEX columns. --- Altering distribution policy for subpartitioned tables -CREATE TABLE mpp6489 -( - id int, - rank int, - year date, - gender char(1) -) -DISTRIBUTED BY (id, gender, year) -partition by list (gender) -subpartition by range (year) -subpartition template -( - start (date '2001-01-01'), - start (date '2002-01-01'), - start (date '2003-01-01'), - start (date '2004-01-01'), - start (date '2005-01-01') -) -( - values ('M'), - values ('F') -); -ALTER TABLE mpp6489_1_prt_1_2_prt_5 set distributed randomly; -ALTER TABLE "mpp6489" ALTER PARTITION FOR('M'::bpchar) alter PARTITION -FOR(RANK(5)) set distributed by (id, gender, year); -NOTICE: altering table "mpp6489_1_prt_1_2_prt_5" (partition for rank 5 of partition for value ('M'::bpchar) of relation "mpp6489") -- Altering distribution policy for temp tables create temp table atsdb (c1 int, c2 int) distributed randomly; select * from atsdb; diff --git a/src/test/regress/expected/bfv_partition.out b/src/test/regress/expected/bfv_partition.out index c2a6f4df9c..fb06d09665 100644 --- a/src/test/regress/expected/bfv_partition.out +++ b/src/test/regress/expected/bfv_partition.out @@ -451,6 +451,8 @@ 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; +ERROR: can't set the distribution policy of "pt_1_prt_1" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. 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. diff --git a/src/test/regress/expected/direct_dispatch.out b/src/test/regress/expected/direct_dispatch.out index 6331af47a3..9248664ae9 100644 --- a/src/test/regress/expected/direct_dispatch.out +++ b/src/test/regress/expected/direct_dispatch.out @@ -528,8 +528,8 @@ INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 -- One partition is randomly distributed, while others are distributed by key. alter table ddtesttab_1_prt_2 set distributed randomly; -INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 -INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 +ERROR: can't set the distribution policy of "ddtesttab_1_prt_2" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. insert into ddtesttab values (1, 1, 5); INFO: (slice 0) Dispatch command to SINGLE content INFO: Distributed transaction command 'Distributed Prepare' to SINGLE content @@ -540,9 +540,10 @@ INFO: (slice 1) Dispatch command to SINGLE content INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 insert into ddtesttab values (1, 1, nextval('ddtestseq')); -INFO: (slice 0) Dispatch command to SINGLE content -INFO: Distributed transaction command 'Distributed Prepare' to SINGLE content -INFO: Distributed transaction command 'Distributed Commit Prepared' to SINGLE content +INFO: (slice 0) Dispatch command to ALL contents: 0 1 2 +INFO: (slice 1) Dispatch command to SINGLE content +INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 +INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 insert into ddtesttab values (1, 1, 5 + nextval('ddtestseq')); INFO: (slice 0) Dispatch command to ALL contents: 0 1 2 INFO: (slice 1) Dispatch command to SINGLE content diff --git a/src/test/regress/expected/direct_dispatch_optimizer.out b/src/test/regress/expected/direct_dispatch_optimizer.out index b9dc94a9e7..769ce1ccde 100644 --- a/src/test/regress/expected/direct_dispatch_optimizer.out +++ b/src/test/regress/expected/direct_dispatch_optimizer.out @@ -536,8 +536,8 @@ INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 -- One partition is randomly distributed, while others are distributed by key. alter table ddtesttab_1_prt_2 set distributed randomly; -INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2 -INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2 +ERROR: can't set the distribution policy of "ddtesttab_1_prt_2" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. insert into ddtesttab values (1, 1, 5); INFO: (slice 0) Dispatch command to SINGLE content INFO: Distributed transaction command 'Distributed Prepare' to SINGLE content diff --git a/src/test/regress/expected/gpdist.out b/src/test/regress/expected/gpdist.out index 60fda7bff7..74ace0faf9 100644 --- a/src/test/regress/expected/gpdist.out +++ b/src/test/regress/expected/gpdist.out @@ -283,7 +283,7 @@ SELECT * from customer_off a, customer_off b where a.gp_segment_id <> b.gp_segme -----------+--------+-----------+-------------+---------+-----------+--------------+-----------+-----------+--------+-----------+-------------+---------+-----------+--------------+----------- (0 rows) --- Test partitioned tables which have child with different distribution policies +-- Test partitioned tables which have child with same distribution policies set gp_enable_fast_sri to on; -- single level case create table pt (i int, j int, k int) distributed by (i) partition by range(k) @@ -294,12 +294,14 @@ 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 by (j); -ERROR: cannot SET DISTRIBUTED BY for pt_1_prt_1 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. +ERROR: can't set the distribution policy of "pt_1_prt_1" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. alter table pt_1_prt_2 set distributed randomly; +ERROR: can't set the distribution policy of "pt_1_prt_2" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. alter table pt_1_prt_2 set distributed by (k); -ERROR: cannot SET DISTRIBUTED BY for pt_1_prt_2 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. +ERROR: can't set the distribution policy of "pt_1_prt_2" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. insert into pt values(1, 1, 1); insert into pt values(2, 2, 2); insert into pt values(3, 3, 3); @@ -394,8 +396,8 @@ select gp_segment_id, * from pt_2; (0 rows) alter table pt_1_prt_2_2_prt_1 set distributed by (j); -ERROR: cannot SET DISTRIBUTED BY for pt_1_prt_2_2_prt_1 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. +ERROR: can't set the distribution policy of "pt_1_prt_2_2_prt_1" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. insert into pt values(45, 45, 45, 'A'); insert into pt values(45, 46, 46, 'A'); insert into pt values(45, 47, 47, 'A'); diff --git a/src/test/regress/expected/gpdist_optimizer.out b/src/test/regress/expected/gpdist_optimizer.out index 84efbef2eb..8ea4448bfb 100644 --- a/src/test/regress/expected/gpdist_optimizer.out +++ b/src/test/regress/expected/gpdist_optimizer.out @@ -283,7 +283,7 @@ SELECT * from customer_off a, customer_off b where a.gp_segment_id <> b.gp_segme -----------+--------+-----------+-------------+---------+-----------+--------------+-----------+-----------+--------+-----------+-------------+---------+-----------+--------------+----------- (0 rows) --- Test partitioned tables which have child with different distribution policies +-- Test partitioned tables which have child with same distribution policies set gp_enable_fast_sri to on; -- single level case create table pt (i int, j int, k int) distributed by (i) partition by range(k) @@ -294,12 +294,14 @@ 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 by (j); -ERROR: cannot SET DISTRIBUTED BY for pt_1_prt_1 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. +ERROR: can't set the distribution policy of "pt_1_prt_1" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. alter table pt_1_prt_2 set distributed randomly; +ERROR: can't set the distribution policy of "pt_1_prt_2" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. alter table pt_1_prt_2 set distributed by (k); -ERROR: cannot SET DISTRIBUTED BY for pt_1_prt_2 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. +ERROR: can't set the distribution policy of "pt_1_prt_2" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. insert into pt values(1, 1, 1); insert into pt values(2, 2, 2); insert into pt values(3, 3, 3); @@ -394,8 +396,8 @@ select gp_segment_id, * from pt_2; (0 rows) alter table pt_1_prt_2_2_prt_1 set distributed by (j); -ERROR: cannot SET DISTRIBUTED BY for pt_1_prt_2_2_prt_1 -HINT: Leaf distribution policy must be random or match that of the entire partitioned table. +ERROR: can't set the distribution policy of "pt_1_prt_2_2_prt_1" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. insert into pt values(45, 45, 45, 'A'); insert into pt values(45, 46, 46, 'A'); insert into pt values(45, 47, 47, 'A'); diff --git a/src/test/regress/expected/metadata_track.out b/src/test/regress/expected/metadata_track.out index 05020382d5..5a3c46ee11 100644 --- a/src/test/regress/expected/metadata_track.out +++ b/src/test/regress/expected/metadata_track.out @@ -153,8 +153,12 @@ NOTICE: CREATE TABLE will create partition "mdt_test_part1_1_prt_2" for table " NOTICE: CREATE TABLE will create partition "mdt_test_part1_1_prt_1_2_prt_1" for table "mdt_test_part1_1_prt_1" NOTICE: CREATE TABLE will create partition "mdt_test_part1_1_prt_2_2_prt_1" for table "mdt_test_part1_1_prt_2" alter table mdt_test_part1_1_prt_1_2_prt_1 set distributed randomly; +ERROR: can't set the distribution policy of "mdt_test_part1_1_prt_1_2_prt_1" +HINT: Distribution policy can be set for an entire partitioned table, not for one of its leaf parts or an interior branch. ALTER TABLE mdt_test_part1 ALTER PARTITION FOR('M'::bpchar) alter PARTITION FOR(RANK(1)) set distributed by (id, gender, year); NOTICE: altering table "mdt_test_part1_1_prt_1_2_prt_1" (partition for rank 1 of partition for value ('M'::bpchar) of relation "mdt_test_part1") +WARNING: distribution policy of relation "mdt_test_part1_1_prt_1_2_prt_1" already set to (id,gender,year) +HINT: Use ALTER TABLE "mdt_test_part1_1_prt_1_2_prt_1" SET WITH (REORGANIZE=TRUE) DISTRIBUTED BY (id,gender,year) to force redistribution drop table mdt_test_part1; -- create table mdt_part_tbl_subpartition (a char, b int, d char) diff --git a/src/test/regress/input/gpcopy.source b/src/test/regress/input/gpcopy.source index dfa13874e1..29d97363c3 100644 --- a/src/test/regress/input/gpcopy.source +++ b/src/test/regress/input/gpcopy.source @@ -1072,11 +1072,6 @@ COPY COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED FROM '/tmp/COPY_ON_SEGMENT_CHECK_DI SET gp_enable_segment_copy_checking=on; set gp_vmem_idle_resource_timeout=18000; --- If the partition is made randomly distributed, it works even with the --- checking enabled. -ALTER table copy_on_segment_check_distkey_partioned_1_prt_1 set DISTRIBUTED RANDOMLY ; -COPY COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED.csv' ON SEGMENT CSV; - -- But make sure we still perform the checks for the other partition that is -- hash distributed. COPY COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED_1_prt_2 to '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED0.csv' CSV; @@ -1119,8 +1114,6 @@ SELECT COUNT(*) FROM COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION; COPY COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION to '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION0.csv' CSV; COPY COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION.csv' ON SEGMENT CSV; -ALTER table copy_on_segment_check_distkey_subpartition_1_prt_1_2_prt_1 set DISTRIBUTED RANDOMLY ; -COPY COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION.csv' ON SEGMENT CSV; -- start_ignore DROP TABLE IF EXISTS LINEITEM_1; DROP TABLE IF EXISTS LINEITEM_2; diff --git a/src/test/regress/output/gpcopy.source b/src/test/regress/output/gpcopy.source index bb52b238cc..ead04ac4b2 100755 --- a/src/test/regress/output/gpcopy.source +++ b/src/test/regress/output/gpcopy.source @@ -1267,10 +1267,6 @@ SET gp_enable_segment_copy_checking=off; COPY COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED.csv' ON SEGMENT CSV; SET gp_enable_segment_copy_checking=on; set gp_vmem_idle_resource_timeout=18000; --- If the partition is made randomly distributed, it works even with the --- checking enabled. -ALTER table copy_on_segment_check_distkey_partioned_1_prt_1 set DISTRIBUTED RANDOMLY ; -COPY COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED.csv' ON SEGMENT CSV; -- But make sure we still perform the checks for the other partition that is -- hash distributed. COPY COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED_1_prt_2 to '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_PARTIONED0.csv' CSV; @@ -1341,9 +1337,6 @@ COPY COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION to '/tmp/COPY_ON_SEGMENT_CHECK_D COPY COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION.csv' ON SEGMENT CSV; ERROR: value of distribution key doesn't belong to segment with ID 0, it belongs to segment with ID 1 (seg0 127.0.0.1:40000 pid=13100) CONTEXT: COPY copy_on_segment_check_distkey_subpartition, line 2: "0,0" -ALTER table copy_on_segment_check_distkey_subpartition_1_prt_1_2_prt_1 set DISTRIBUTED RANDOMLY ; -COPY COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION FROM '/tmp/COPY_ON_SEGMENT_CHECK_DISTKEY_SUBPARTITION.csv' ON SEGMENT CSV; -ERROR: value of distribution key doesn't belong to segment with ID 0, it belongs to segment with ID 1 (seg0 127.0.0.1:40000 pid=31639) -- start_ignore DROP TABLE IF EXISTS LINEITEM_1; DROP TABLE IF EXISTS LINEITEM_2; diff --git a/src/test/regress/sql/alter_distribution_policy.sql b/src/test/regress/sql/alter_distribution_policy.sql index 35be15e920..ae76e6a081 100644 --- a/src/test/regress/sql/alter_distribution_policy.sql +++ b/src/test/regress/sql/alter_distribution_policy.sql @@ -75,67 +75,6 @@ alter table atsdb_ao set distributed randomly; select count(*) from atsdb_ao; drop table atsdb_ao; --- Check divergent distribution policies for partitioning. -create table atsdb (i int, j int, k int) distributed by (i) partition by range(k) -(start(1) end(4) every(1)); -alter table atsdb_1_prt_2 set distributed by (j); -alter table atsdb_1_prt_3 set distributed randomly; --- test COPY -copy atsdb from stdin delimiter '|'; -1|1|1 -2|1|1 -2|2|1 -3|1|1 -3|2|1 -3|3|1 -1|1|2 -2|1|2 -2|2|2 -3|1|2 -3|2|2 -3|3|2 -1|1|3 -2|1|3 -2|2|3 -3|1|3 -3|2|3 -3|3|3 -\. - -select count(*) from atsdb; - --- compare distribution: we create a table, identical to the partitioned table, --- and compare how the tuples have been distributed. -create table atsdb_1 (like atsdb_1_prt_1) distributed by (i); -copy atsdb_1 from stdin delimiter '|'; -1|1|1 -2|1|1 -2|2|1 -3|1|1 -3|2|1 -3|3|1 -\. -select gp_segment_id, * from atsdb where k = 1 except -select gp_segment_id, * from atsdb_1; - -create table atsdb_2 (like atsdb_1_prt_2) distributed by (i); -copy atsdb_2 from stdin delimiter '|'; -1|1|2 -2|1|2 -2|2|2 -3|1|2 -3|2|2 -3|3|2 -\. -select gp_segment_id, * from atsdb where k = 2 except -select gp_segment_id, * from atsdb_2; - --- Can't test randomly distributed - --- Can't test INSERT (yet) - -drop table atsdb, atsdb_1, atsdb_2; - -- Can't redistribute system catalogs alter table pg_class set distributed by (relname); alter table pg_class set with(appendonly = true); @@ -440,34 +379,6 @@ ALTER TABLE t_dist2 SET DISTRIBUTED BY(col1, col2, col3); ALTER TABLE t_dist2 SET DISTRIBUTED BY(col3); ALTER TABLE t_dist2 SET DISTRIBUTED BY(col4); --- Altering distribution policy for subpartitioned tables -CREATE TABLE mpp6489 -( - id int, - rank int, - year date, - gender char(1) -) -DISTRIBUTED BY (id, gender, year) -partition by list (gender) -subpartition by range (year) -subpartition template -( - start (date '2001-01-01'), - start (date '2002-01-01'), - start (date '2003-01-01'), - start (date '2004-01-01'), - start (date '2005-01-01') -) -( - values ('M'), - values ('F') -); - -ALTER TABLE mpp6489_1_prt_1_2_prt_5 set distributed randomly; -ALTER TABLE "mpp6489" ALTER PARTITION FOR('M'::bpchar) alter PARTITION -FOR(RANK(5)) set distributed by (id, gender, year); - -- Altering distribution policy for temp tables create temp table atsdb (c1 int, c2 int) distributed randomly; select * from atsdb; diff --git a/src/test/regress/sql/gpdist.sql b/src/test/regress/sql/gpdist.sql index c1c09dc38e..4cfda39677 100644 --- a/src/test/regress/sql/gpdist.sql +++ b/src/test/regress/sql/gpdist.sql @@ -285,7 +285,7 @@ INSERT INTO customer_on VALUES (599, 'Customer#000000599', 'fIvpza0tlXAVjOAPkWN5 SELECT * from customer_off a, customer_off b where a.gp_segment_id <> b.gp_segment_id and a.c_custkey = b.c_custkey; --- Test partitioned tables which have child with different distribution policies +-- Test partitioned tables which have child with same distribution policies set gp_enable_fast_sri to on; -- single level case -- GitLab