partition1.out 140.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
set enable_partition_rules = false;
set gp_enable_hash_partitioned_tables = true;
-- missing subpartition by
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
ERROR:  missing SUBPARTITION BY clause for subpartition specification
LINE 5: partition aa (subpartition cc, subpartition dd),
        ^
-- missing subpartition spec
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
(
partition aa ,
partition bb 
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
ERROR:  hash partition requires PARTITIONS clause or partition specification
LINE 4: subpartition by hash (d) 
                        ^
-- subpart spec conflict
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b) 
subpartition by hash (d) subpartition template (subpartition jjj)
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
ERROR:  subpartition configuration conflicts with subpartition template
LINE 4: subpartition by hash (d) subpartition template (subpartition...
                        ^
-- missing subpartition by
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
subpartition by hash (d)
(
partition aa (subpartition cc, subpartition dd (subpartition iii)),
partition bb (subpartition cc, subpartition dd)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
ERROR:  missing SUBPARTITION BY clause for subpartition specification (at depth 2)
LINE 6: partition aa (subpartition cc, subpartition dd (subpartition...
                                       ^
-- Test column lookup works
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash(doesnotexist)
partitions 3;
ERROR:  column "doesnotexist" does not exist in relation "ggg"
LINE 3: partition by hash(doesnotexist)
                     ^
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash(b)
partitions 3
subpartition by list(alsodoesntexist)
subpartition template (
subpartition aa values(1)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1" for table "ggg"
ERROR:  column "alsodoesntexist" does not exist in relation "ggg_1_prt_1"
LINE 5: subpartition by list(alsodoesntexist)
                        ^
-- should work
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
85
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
drop table ggg cascade;
-- disable hash partitions
set gp_enable_hash_partitioned_tables = false;
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
ERROR:  PARTITION BY must specify RANGE or LIST
drop table ggg cascade;
ERROR:  table "ggg" does not exist
set gp_enable_hash_partitioned_tables = true;
-- should work
create table ggg (a char(1), b char(2), d char(3), e int)
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
subpartition template ( 
subpartition cc,
subpartition dd
), 
subpartition by hash (e) 
subpartition template ( 
subpartition ee,
subpartition ff
) 
(
partition aa,
partition bb
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ee" for table "ggg_1_prt_aa_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ff" for table "ggg_1_prt_aa_2_prt_cc"
125
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
126 127
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ee" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ff" for table "ggg_1_prt_aa_2_prt_dd"
128
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
129 130 131
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ee" for table "ggg_1_prt_bb_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ff" for table "ggg_1_prt_bb_2_prt_cc"
132
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ee" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ff" for table "ggg_1_prt_bb_2_prt_dd"
drop table ggg cascade;
-- should work
create table ggg (a char(1), b char(2), d char(3), e int)
distributed by (a)
partition by hash (b)
subpartition by hash (d),
subpartition by hash (e)
subpartition template ( 
subpartition ee,
subpartition ff
) 
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ee" for table "ggg_1_prt_aa_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ff" for table "ggg_1_prt_aa_2_prt_cc"
154
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
155 156
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ee" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ff" for table "ggg_1_prt_aa_2_prt_dd"
157
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
158 159 160
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ee" for table "ggg_1_prt_bb_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ff" for table "ggg_1_prt_bb_2_prt_cc"
161
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ee" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ff" for table "ggg_1_prt_bb_2_prt_dd"
drop table ggg cascade;
-- doesn't work because cannot have nested declaration in template
create table ggg (a char(1), b char(2), d char(3), e int)
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
subpartition template ( 
subpartition cc (subpartition ee, subpartition ff),
subpartition dd (subpartition ee, subpartition ff)
), 
subpartition by hash (e) 
(
partition aa,
partition bb
);
ERROR:  template cannot contain specification for child partition
drop table ggg cascade;
ERROR:  table "ggg" does not exist
--ERROR: Missing boundary specification in partition 'aa' of type LIST 
create table fff (a char(1), b char(2), d char(3)) distributed by
(a) partition by list (b) (partition aa ); 
ERROR:  missing boundary specification in partition "aa" of type LIST
LINE 2: (a) partition by list (b) (partition aa );
                                   ^
-- ERROR: Invalid use of RANGE boundary specification in partition
--   number 1 of type LIST
create table fff (a char(1), b char(2), d char(3)) distributed by (a)
partition by list (b) (start ('a') );
ERROR:  invalid boundary specification for LIST partition
LINE 2: partition by list (b) (start ('a') );
                               ^
-- should work
create table fff (a char(1), b char(2), d char(3)) distributed by (a)
partition by list (b) (partition aa values ('2'));
NOTICE:  CREATE TABLE will create partition "fff_1_prt_aa" for table "fff"
drop table fff cascade;
-- Invalid use of RANGE boundary specification in partition "cc" of 
-- type HASH (at depth 2)
create table ggg (a char(1), b char(2), d char(3), e int) distributed by (a)
partition by hash (b) subpartition by hash (d),
subpartition by hash (e) 
subpartition template ( subpartition ee, subpartition ff ) (
partition aa (subpartition cc, subpartition dd), partition bb
(subpartition cc start ('a') , subpartition dd) );
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ee" for table "ggg_1_prt_aa_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ff" for table "ggg_1_prt_aa_2_prt_cc"
212
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
213 214
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ee" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ff" for table "ggg_1_prt_aa_2_prt_dd"
215
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
ERROR:  invalid use of RANGE boundary specification in partition "cc" of type HASH (at depth 2)
LINE 6: (subpartition cc start ('a') , subpartition dd) );
                         ^
-- this is subtly wrong -- it defines 4 partitions
-- the problem is the comma before "end", which causes us to
-- generate 2 anonymous partitions.
-- This is an error: 
-- ERROR:  invalid use of mixed named and unnamed RANGE boundary specifications
create table ggg (a char(1), b int, d char(3))
distributed by (a)
partition by range (b)
(
partition aa start ('2007'), end ('2008'),
partition bb start ('2008'), end ('2009')
);
ERROR:  invalid use of mixed named and unnamed RANGE boundary specifications
LINE 5: partition aa start ('2007'), end ('2008'),
                                     ^
create table ggg (a char(1), b int)
distributed by (a)
partition by range(b)
(
partition aa start ('2007'), end ('2008')
);
ERROR:  invalid use of mixed named and unnamed RANGE boundary specifications
LINE 5: partition aa start ('2007'), end ('2008')
                                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
create table ggg (a char(1), b date, d char(3))
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01'),
partition bb start (date '2008-01-01') end (date '2009-01-01')
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
drop table ggg cascade;
-- don't allow nonconstant expressions, even simple ones...
create table ggg (a char(1), b numeric, d numeric)
distributed by (a)
partition by range (b,d)
(
partition aa start (2007,1) end (2008,2+2),
partition bb start (2008,2) end (2009,3)
);
ERROR:  syntax error at or near "+"
LINE 5: partition aa start (2007,1) end (2008,2+2),
                                               ^
-- too many columns for RANGE partition
create table ggg (a char(1), b numeric, d numeric)
distributed by (a)
partition by range (b,d)
(
partition aa start (2007,1) end (2008,2),
partition bb start (2008,2) end (2009,3)
);
ERROR:  too many columns for RANGE partition -- only one column is allowed.
LINE 3: partition by range (b,d)
                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
-- demo starts here
-- nested subpartitions
create table ggg
 (a char(1),   b date,
  d char(3),  e numeric,
  f numeric,  g numeric,
  h numeric)
distributed by (a)
partition by hash(b)
partitions 2
subpartition by hash(d)
subpartitions 2,
subpartition by hash(e) subpartitions 2,
subpartition by hash(f) subpartitions 2,
subpartition by hash(g) subpartitions 2,
subpartition by hash(h) subpartitions 2;
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1" for table "ggg_1_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1" for table "ggg_1_prt_1_2_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_1"
302
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1"
303 304
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_1_5_prt_2"
305
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1"
306 307 308
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_1"
309
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2"
310 311
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_1_4_prt_2_5_prt_2"
312
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2" for table "ggg_1_prt_1_2_prt_1"
313 314 315 316
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_1"
317
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1"
318 319
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_1_5_prt_2"
320
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2"
321 322 323
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_1"
324
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2"
325 326
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_1_3_prt_2_4_prt_2_5_prt_2"
327
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2" for table "ggg_1_prt_1"
328 329 330 331 332
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1" for table "ggg_1_prt_1_2_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_1"
333
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1"
334 335
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_1_5_prt_2"
336
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1"
337 338 339
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_1"
340
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2"
341 342
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_1_4_prt_2_5_prt_2"
343
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2" for table "ggg_1_prt_1_2_prt_2"
344 345 346 347
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_1"
348
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1"
349 350
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_1_5_prt_2"
351
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2"
352 353 354
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_1"
355
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2"
356 357
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_1_2_prt_2_3_prt_2_4_prt_2_5_prt_2"
358
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2" for table "ggg"
359 360 361 362 363 364
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1" for table "ggg_1_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1" for table "ggg_1_prt_2_2_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_1"
365
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1"
366 367
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_1_5_prt_2"
368
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1"
369 370 371
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_1"
372
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2"
373 374
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_1_4_prt_2_5_prt_2"
375
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2" for table "ggg_1_prt_2_2_prt_1"
376 377 378 379
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_1"
380
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1"
381 382
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_1_5_prt_2"
383
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2"
384 385 386
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_1"
387
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2"
388 389
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_1_3_prt_2_4_prt_2_5_prt_2"
390
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2" for table "ggg_1_prt_2"
391 392 393 394 395
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1" for table "ggg_1_prt_2_2_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_1"
396
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1"
397 398
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_1_5_prt_2"
399
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1"
400 401 402
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_1"
403
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2"
404 405
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_1_4_prt_2_5_prt_2"
406
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2" for table "ggg_1_prt_2_2_prt_2"
407 408 409 410
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_1"
411
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1"
412 413
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_1_5_prt_2"
414
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2"
415 416 417
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_1_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_1"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_1_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_1"
418
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2"
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_2_6_prt_1" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_2"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_2_6_prt_2" for table "ggg_1_prt_2_2_prt_2_3_prt_2_4_prt_2_5_prt_2"
drop table ggg cascade;
-- named, inline subpartitions
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
434
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
drop table ggg cascade;
-- subpartitions with templates
create table ggg (a char(1), b char(2), d char(3), e numeric)
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
subpartition template ( 
subpartition cc,
subpartition dd
), 
subpartition by hash (e) 
subpartition template ( 
subpartition ee,
subpartition ff
) 
(
partition aa,
partition bb
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ee" for table "ggg_1_prt_aa_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ff" for table "ggg_1_prt_aa_2_prt_cc"
460
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
461 462
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ee" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ff" for table "ggg_1_prt_aa_2_prt_dd"
463
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
464 465 466
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ee" for table "ggg_1_prt_bb_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ff" for table "ggg_1_prt_bb_2_prt_cc"
467
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ee" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ff" for table "ggg_1_prt_bb_2_prt_dd"
drop table ggg cascade;
-- mixed inline subpartition declarations with templates
create table ggg (a char(1), b char(2), d char(3), e numeric)
distributed by (a)
partition by hash (b)
subpartition by hash (d) , 
subpartition by hash (e) 
subpartition template ( 
subpartition ee,
subpartition ff
) 
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ee" for table "ggg_1_prt_aa_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc_3_prt_ff" for table "ggg_1_prt_aa_2_prt_cc"
489
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
490 491
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ee" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_ff" for table "ggg_1_prt_aa_2_prt_dd"
492
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
493 494 495
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ee" for table "ggg_1_prt_bb_2_prt_cc"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc_3_prt_ff" for table "ggg_1_prt_bb_2_prt_cc"
496
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ee" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_ff" for table "ggg_1_prt_bb_2_prt_dd"
drop table ggg cascade;
-- basic list partition
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by LIST (b)
(
partition aa values ('a', 'b', 'c', 'd'),
partition bb values ('e', 'f', 'g')
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
insert into ggg values ('x', 'a');
insert into ggg values ('x', 'b');
insert into ggg values ('x', 'c');
insert into ggg values ('x', 'd');
insert into ggg values ('x', 'e');
insert into ggg values ('x', 'f');
insert into ggg values ('x', 'g');
insert into ggg values ('x', 'a');
insert into ggg values ('x', 'b');
insert into ggg values ('x', 'c');
insert into ggg values ('x', 'd');
insert into ggg values ('x', 'e');
insert into ggg values ('x', 'f');
insert into ggg values ('x', 'g');
select * from ggg order by 1, 2;
 a | b  | d 
---+----+---
 x | a  | 
 x | a  | 
 x | b  | 
 x | b  | 
 x | c  | 
 x | c  | 
 x | d  | 
 x | d  | 
 x | e  | 
 x | e  | 
 x | f  | 
 x | f  | 
 x | g  | 
 x | g  | 
(14 rows)

-- ok
select * from ggg_1_prt_aa order by 1, 2;
 a | b  | d 
---+----+---
 x | a  | 
 x | a  | 
 x | b  | 
 x | b  | 
 x | c  | 
 x | c  | 
 x | d  | 
 x | d  | 
(8 rows)

select * from ggg_1_prt_bb order by 1, 2;
 a | b  | d 
---+----+---
 x | e  | 
 x | e  | 
 x | f  | 
 x | f  | 
 x | g  | 
 x | g  | 
(6 rows)

drop table ggg cascade;
-- documentation example - partition by list and range
CREATE TABLE rank (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')
)
(
  partition boys values ('M'),
  partition girls values ('F')
);
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys" for table "rank"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_1" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_2" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_3" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_4" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_5" for table "rank_1_prt_boys"
591
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls" for table "rank"
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_1" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_2" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_3" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_4" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_5" for table "rank_1_prt_girls"
insert into rank values (1, 1, date '2001-01-15', 'M');
insert into rank values (2, 1, date '2002-02-15', 'M');
insert into rank values (3, 1, date '2003-03-15', 'M');
insert into rank values (4, 1, date '2004-04-15', 'M');
insert into rank values (5, 1, date '2005-05-15', 'M');
insert into rank values (6, 1, date '2001-01-15', 'F');
insert into rank values (7, 1, date '2002-02-15', 'F');
insert into rank values (8, 1, date '2003-03-15', 'F');
insert into rank values (9, 1, date '2004-04-15', 'F');
insert into rank values (10, 1, date '2005-05-15', 'F');
select * from rank order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  1 |    1 | 01-15-2001 | M
  2 |    1 | 02-15-2002 | M
  3 |    1 | 03-15-2003 | M
  4 |    1 | 04-15-2004 | M
  5 |    1 | 05-15-2005 | M
  6 |    1 | 01-15-2001 | F
  7 |    1 | 02-15-2002 | F
  8 |    1 | 03-15-2003 | F
  9 |    1 | 04-15-2004 | F
 10 |    1 | 05-15-2005 | F
(10 rows)

select * from rank_1_prt_boys order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  1 |    1 | 01-15-2001 | M
  2 |    1 | 02-15-2002 | M
  3 |    1 | 03-15-2003 | M
  4 |    1 | 04-15-2004 | M
  5 |    1 | 05-15-2005 | M
(5 rows)

select * from rank_1_prt_girls order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  6 |    1 | 01-15-2001 | F
  7 |    1 | 02-15-2002 | F
  8 |    1 | 03-15-2003 | F
  9 |    1 | 04-15-2004 | F
 10 |    1 | 05-15-2005 | F
(5 rows)

select * from rank_1_prt_girls_2_prt_1 order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  6 |    1 | 01-15-2001 | F
(1 row)

select * from rank_1_prt_girls_2_prt_2 order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  7 |    1 | 02-15-2002 | F
(1 row)

drop table rank cascade;
-- range list hash combo
create table ggg (a char(1), b date, d char(3), e numeric)
distributed by (a)
partition by range (b)
subpartition by list(d),
subpartition by hash(e) subpartitions 3
(
partition aa 
start  (date '2007-01-01') 
end (date '2008-01-01') 
       (subpartition dd values ('1', '2', '3'), 
	    subpartition ee values ('4', '5', '6')),
partition bb
start  (date '2008-01-01') 
end (date '2009-01-01') 
       (subpartition dd values ('1', '2', '3'),
	    subpartition ee values ('4', '5', '6'))
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_1" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_2" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_3" for table "ggg_1_prt_aa_2_prt_dd"
678
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee" for table "ggg_1_prt_aa"
679 680 681
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee_3_prt_1" for table "ggg_1_prt_aa_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee_3_prt_2" for table "ggg_1_prt_aa_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee_3_prt_3" for table "ggg_1_prt_aa_2_prt_ee"
682
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
683 684 685 686
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_1" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_2" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_3" for table "ggg_1_prt_bb_2_prt_dd"
687
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee" for table "ggg_1_prt_bb"
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee_3_prt_1" for table "ggg_1_prt_bb_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee_3_prt_2" for table "ggg_1_prt_bb_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee_3_prt_3" for table "ggg_1_prt_bb_2_prt_ee"
drop table ggg cascade;
-- demo ends here
-- LIST validation
-- duplicate partition name
CREATE TABLE rank (id int, rank int, year date, gender
char(1)) DISTRIBUTED BY (id, gender, year)
partition by list (gender)
(
  partition boys values ('M'),
  partition girls values ('a'),
  partition girls values ('b'),
  partition girls values ('c'),
  partition girls values ('d'),
  partition girls values ('e'),
  partition bob values ('M')
);
ERROR:  duplicate partition name for partition "girls"
LINE 7:   partition girls values ('b'),
          ^
-- duplicate values
CREATE TABLE rank (id int, rank int, year date, gender
char(1)) DISTRIBUTED BY (id, gender, year)
partition by list (rank,gender)
(
 values ((1, 'M')),
 values ((2, 'M')),
 values ((3, 'M')),
 values ((1, 'F')),
 partition ff values ((4, 'M')),
 partition bb values ((1, 'M'))
);
ERROR:  duplicate VALUES in partition "bb"
LINE 10:  partition bb values ((1, 'M'))
                       ^
-- RANGE validation
-- legal if end of aa not inclusive
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01'),
partition bb start (date '2008-01-01') end (date '2009-01-01') 
every (interval '10 days'));
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_3" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_4" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_5" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_6" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_7" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_8" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_9" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_10" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_11" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_12" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_13" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_14" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_15" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_16" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_17" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_18" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_19" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_20" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_21" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_22" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_23" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_24" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_25" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_26" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_27" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_28" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_29" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_30" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_31" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_32" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_33" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_34" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_35" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_36" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_37" for table "ggg"
drop table ggg cascade;
-- bad - legal if end of aa not inclusive
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01') inclusive,
partition bb start (date '2008-01-01') end (date '2009-01-01') 
every (interval '10 days'));
ERROR:  starting value of partition "bb_1" overlaps previous range
LINE 6: partition bb start (date '2008-01-01') end (date '2009-01-01...
                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
-- legal because start of bb not inclusive
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01') inclusive,
partition bb start (date '2008-01-01') exclusive end (date '2009-01-01') 
every (interval '10 days'));
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_3" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_4" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_5" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_6" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_7" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_8" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_9" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_10" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_11" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_12" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_13" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_14" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_15" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_16" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_17" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_18" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_19" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_20" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_21" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_22" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_23" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_24" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_25" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_26" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_27" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_28" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_29" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_30" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_31" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_32" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_33" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_34" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_35" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_36" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_37" for table "ggg"
drop table ggg cascade;
-- legal if end of aa not inclusive
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition bb start (date '2008-01-01') end (date '2009-01-01'),
partition aa start (date '2007-01-01') end (date '2008-01-01')
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
drop table ggg cascade;
-- bad - legal if end of aa not inclusive
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition bb start (date '2008-01-01') end (date '2009-01-01'),
partition aa start (date '2007-01-01') end (date '2008-01-01') inclusive
);
ERROR:  starting value of partition "bb" overlaps previous range
LINE 5: partition bb start (date '2008-01-01') end (date '2009-01-01...
                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
-- legal because start of bb not inclusive
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition bb start (date '2008-01-01') exclusive end (date '2009-01-01'),
partition aa start (date '2007-01-01') end (date '2008-01-01') inclusive
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
drop table ggg cascade;
-- validate aa - start greater than end
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition bb start (date '2008-01-01') end (date '2009-01-01'),
partition aa start (date '2007-01-01') end (date '2006-01-01')
);
ERROR:  START greater than END for partition "aa"
LINE 6: partition aa start (date '2007-01-01') end (date '2006-01-01...
                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
-- formerly we could not set end of first partition because next is before
-- but we can sort them now so this is legal.
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition bb start (date '2008-01-01') ,
partition aa start (date '2007-01-01') 
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
drop table ggg cascade;
-- test cross type coercion
-- int -> char(N)
create table ggg (i int, a char(1))
distributed by (i)
partition by list(a)
(partition aa values(1, 2));
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
drop table ggg cascade;
-- int -> numeric
create table ggg (i int, n numeric(20, 2))
distributed by (i)
partition by list(n)
(partition aa values(1.22, 4.1));
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
drop table ggg cascade;
-- EVERY
--  the documentation example, rewritten with EVERY in a template
CREATE TABLE rank (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')
end (date '2006-01-01') every (interval '1 year')) (
partition boys values ('M'),
partition girls values ('F')
);
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys" for table "rank"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_1" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_2" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_3" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_4" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_5" for table "rank_1_prt_boys"
927
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls" for table "rank"
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_1" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_2" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_3" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_4" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_5" for table "rank_1_prt_girls"
insert into rank values (1, 1, date '2001-01-15', 'M');
insert into rank values (2, 1, date '2002-02-15', 'M');
insert into rank values (3, 1, date '2003-03-15', 'M');
insert into rank values (4, 1, date '2004-04-15', 'M');
insert into rank values (5, 1, date '2005-05-15', 'M');
insert into rank values (6, 1, date '2001-01-15', 'F');
insert into rank values (7, 1, date '2002-02-15', 'F');
insert into rank values (8, 1, date '2003-03-15', 'F');
insert into rank values (9, 1, date '2004-04-15', 'F');
insert into rank values (10, 1, date '2005-05-15', 'F');
select * from rank order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  1 |    1 | 01-15-2001 | M
  2 |    1 | 02-15-2002 | M
  3 |    1 | 03-15-2003 | M
  4 |    1 | 04-15-2004 | M
  5 |    1 | 05-15-2005 | M
  6 |    1 | 01-15-2001 | F
  7 |    1 | 02-15-2002 | F
  8 |    1 | 03-15-2003 | F
  9 |    1 | 04-15-2004 | F
 10 |    1 | 05-15-2005 | F
(10 rows)

select * from rank_1_prt_boys order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  1 |    1 | 01-15-2001 | M
  2 |    1 | 02-15-2002 | M
  3 |    1 | 03-15-2003 | M
  4 |    1 | 04-15-2004 | M
  5 |    1 | 05-15-2005 | M
(5 rows)

select * from rank_1_prt_girls order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  6 |    1 | 01-15-2001 | F
  7 |    1 | 02-15-2002 | F
  8 |    1 | 03-15-2003 | F
  9 |    1 | 04-15-2004 | F
 10 |    1 | 05-15-2005 | F
(5 rows)

select * from rank_1_prt_girls_2_prt_1 order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  6 |    1 | 01-15-2001 | F
(1 row)

select * from rank_1_prt_girls_2_prt_2 order by 1, 2, 3, 4;
 id | rank |    year    | gender 
----+------+------------+--------
  7 |    1 | 02-15-2002 | F
(1 row)

drop table rank cascade;
-- integer ranges work too
create table ggg (id integer, a integer)
distributed by (id)
partition by range (a)
(start (1) end (10) every (1));
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_3" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_4" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_5" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_6" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_7" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_8" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_9" for table "ggg"
insert into ggg values (1, 1);
insert into ggg values (2, 2);
insert into ggg values (3, 3);
insert into ggg values (4, 4);
insert into ggg values (5, 5);
insert into ggg values (6, 6);
insert into ggg values (7, 7);
insert into ggg values (8, 8);
insert into ggg values (9, 9);
insert into ggg values (10, 10);
1015
ERROR:  no partition for partitioning key  (seg1 xzhangmac:40001 pid=94564)
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
select * from ggg order by 1, 2;
 id | a 
----+---
  1 | 1
  2 | 2
  3 | 3
  4 | 4
  5 | 5
  6 | 6
  7 | 7
  8 | 8
  9 | 9
(9 rows)

select * from ggg_1_prt_1 order by 1, 2;
 id | a 
----+---
  1 | 1
(1 row)

select * from ggg_1_prt_2 order by 1, 2;
 id | a 
----+---
  2 | 2
(1 row)

select * from ggg_1_prt_3 order by 1, 2;
 id | a 
----+---
  3 | 3
(1 row)

select * from ggg_1_prt_4 order by 1, 2;
 id | a 
----+---
  4 | 4
(1 row)

drop table ggg cascade;
-- hash tests
create table ggg (a char(1), b varchar(2), d varchar(2))
distributed by (a)
partition by hash(b)
partitions 3
(partition a, partition b, partition c);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_a" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_b" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_c" for table "ggg"
insert into ggg values (1,1,1);
insert into ggg values (2,2,1);
insert into ggg values (1,3,1);
insert into ggg values (2,2,3);
insert into ggg values (1,4,5);
insert into ggg values (2,2,4);
insert into ggg values (1,5,6);
insert into ggg values (2,7,3);
insert into ggg values (1,'a','b');
insert into ggg values (2,'c','c');
select * from ggg order by 1, 2, 3;
 a | b | d 
---+---+---
 1 | 1 | 1
 1 | 3 | 1
 1 | 4 | 5
 1 | 5 | 6
 1 | a | b
 2 | 2 | 1
 2 | 2 | 3
 2 | 2 | 4
 2 | 7 | 3
 2 | c | c
(10 rows)

--select * from ggg_1_prt_a order by 1, 2, 3;
--select * from ggg_1_prt_b order by 1, 2, 3;
--select * from ggg_1_prt_c order by 1, 2, 3;
drop table ggg cascade;
-- use multiple cols
create table ggg (a char(1), b varchar(2), d varchar(2))
distributed by (a)
partition by hash(b,d)
partitions 3
(partition a, partition b, partition c);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_a" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_b" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_c" for table "ggg"
insert into ggg values (1,1,1);
insert into ggg values (2,2,1);
insert into ggg values (1,3,1);
insert into ggg values (2,2,3);
insert into ggg values (1,4,5);
insert into ggg values (2,2,4);
insert into ggg values (1,5,6);
insert into ggg values (2,7,3);
insert into ggg values (1,'a','b');
insert into ggg values (2,'c','c');
select * from ggg order by 1, 2, 3;
 a | b | d 
---+---+---
 1 | 1 | 1
 1 | 3 | 1
 1 | 4 | 5
 1 | 5 | 6
 1 | a | b
 2 | 2 | 1
 2 | 2 | 3
 2 | 2 | 4
 2 | 7 | 3
 2 | c | c
(10 rows)

--select * from ggg_1_prt_a order by 1, 2, 3;
--select * from ggg_1_prt_b order by 1, 2, 3;
--select * from ggg_1_prt_c order by 1, 2, 3;
drop table ggg cascade;
-- use multiple cols of different types and without a partition spec
create table ggg (a char(1), b varchar(2), d integer, e date)
distributed by (a)
partition by hash(b,d,e)
partitions 3;
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_3" for table "ggg"
insert into ggg values (1,1,1,date '2001-01-15');
insert into ggg values (2,2,1,date '2001-01-15');
insert into ggg values (1,3,1,date '2001-01-15');
insert into ggg values (2,2,3,date '2001-01-15');
insert into ggg values (1,4,5,date '2001-01-15');
insert into ggg values (2,2,4,date '2001-01-15');
insert into ggg values (1,5,6,date '2001-01-15');
insert into ggg values (2,7,3,date '2001-01-15');
insert into ggg values (1,'a',33,date '2001-01-15');
insert into ggg values (2,'c',44,date '2001-01-15');
select * from ggg order by 1, 2, 3, 4;
 a | b | d  |     e      
---+---+----+------------
 1 | 1 |  1 | 01-15-2001
 1 | 3 |  1 | 01-15-2001
 1 | 4 |  5 | 01-15-2001
 1 | 5 |  6 | 01-15-2001
 1 | a | 33 | 01-15-2001
 2 | 2 |  1 | 01-15-2001
 2 | 2 |  3 | 01-15-2001
 2 | 2 |  4 | 01-15-2001
 2 | 7 |  3 | 01-15-2001
 2 | c | 44 | 01-15-2001
(10 rows)

--select * from ggg_1_prt_1 order by 1, 2, 3, 4;
--select * from ggg_1_prt_2 order by 1, 2, 3, 4;
--select * from ggg_1_prt_3 order by 1, 2, 3, 4;
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
drop table ggg cascade;
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partItion by hash(b)
partitions 3;
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_3" for table "ggg"
drop table ggg cascade;
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
ERROR:  missing SUBPARTITION BY clause for subpartition specification
LINE 5: partition aa (subpartition cc, subpartition dd),
        ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
create table ggg (a char(1), b char(2), d char(3))
distributed by (a)
partition by hash (b)
subpartition by hash (d) 
(
partition aa (subpartition cc, subpartition dd),
partition bb (subpartition cc, subpartition dd)
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_cc" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
1199
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_cc" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
drop table ggg cascade;
create table fff (a char(1), b char(2), d char(3)) distributed by (a)
partition by list (b) (partition aa values ('2'));
NOTICE:  CREATE TABLE will create partition "fff_1_prt_aa" for table "fff"
drop table fff cascade;
create table ggg (a char(1), b numeric, d numeric)
distributed by (a)
partition by range (b,d)
(
partition aa start (2007,1) end (2008,2),
partition bb start (2008,2) end (2009,3)
);
ERROR:  too many columns for RANGE partition -- only one column is allowed.
LINE 3: partition by range (b,d)
                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
create table ggg (a char(1), b date, d char(3), e numeric)
distributed by (a)
partition by range (b)
subpartition by list(d),
subpartition by hash(e) subpartitions 3
(
partition aa 
start  (date '2007-01-01') 
end (date '2008-01-01') 
       (subpartition dd values (1,2,3), subpartition ee values (4,5,6)),
partition bb
start  (date '2008-01-01') 
end (date '2009-01-01') 
       (subpartition dd values (1,2,3), subpartition ee values (4,5,6))
);
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd" for table "ggg_1_prt_aa"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_1" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_2" for table "ggg_1_prt_aa_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_dd_3_prt_3" for table "ggg_1_prt_aa_2_prt_dd"
1239
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee" for table "ggg_1_prt_aa"
1240 1241 1242
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee_3_prt_1" for table "ggg_1_prt_aa_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee_3_prt_2" for table "ggg_1_prt_aa_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_aa_2_prt_ee_3_prt_3" for table "ggg_1_prt_aa_2_prt_ee"
1243
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb" for table "ggg"
1244 1245 1246 1247
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd" for table "ggg_1_prt_bb"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_1" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_2" for table "ggg_1_prt_bb_2_prt_dd"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_dd_3_prt_3" for table "ggg_1_prt_bb_2_prt_dd"
1248
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee" for table "ggg_1_prt_bb"
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee_3_prt_1" for table "ggg_1_prt_bb_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee_3_prt_2" for table "ggg_1_prt_bb_2_prt_ee"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_bb_2_prt_ee_3_prt_3" for table "ggg_1_prt_bb_2_prt_ee"
drop table ggg cascade;
create table ggg (a char(1), b date, d char(3)) 
distributed by (a)
partition by range (b)
(
partition bb start (date '2008-01-01') end (date '2009-01-01'),
partition aa start (date '2007-01-01') end (date '2006-01-01')
);
ERROR:  START greater than END for partition "aa"
LINE 6: partition aa start (date '2007-01-01') end (date '2006-01-01...
                     ^
drop table ggg cascade;
ERROR:  table "ggg" does not exist
create table ggg (a char(1), b varchar(2), d varchar(2))
distributed by (a)
partition by hash(b)
partitions 3;
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_1" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_2" for table "ggg"
NOTICE:  CREATE TABLE will create partition "ggg_1_prt_3" for table "ggg"
insert into ggg values (1,1,1);
insert into ggg values (2,2,1);
insert into ggg values (1,3,1);
insert into ggg values (2,2,3);
insert into ggg values (1,4,5);
insert into ggg values (2,2,4);
insert into ggg values (1,5,6);
insert into ggg values (2,7,3);
insert into ggg values (1,'a','b');
insert into ggg values (2,'c','c');
select * from ggg;
 a | b | d 
---+---+---
 1 | 1 | 1
 1 | 3 | 1
 1 | 4 | 5
 1 | 5 | 6
 1 | a | b
 2 | 7 | 3
 2 | 2 | 1
 2 | 2 | 3
 2 | 2 | 4
 2 | c | c
(10 rows)

select * from ggg_1_prt_1;
 a | b | d 
---+---+---
 1 | 1 | 1
 1 | 3 | 1
1302
 2 | 7 | 3
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
(3 rows)

select * from ggg_1_prt_2;
 a | b | d 
---+---+---
 1 | 4 | 5
(1 row)

select * from ggg_1_prt_3;
 a | b | d 
---+---+---
 2 | 2 | 1
 2 | 2 | 3
 2 | 2 | 4
 2 | c | c
1318 1319
 1 | 5 | 6
 1 | a | b
1320 1321
(6 rows)

1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388
drop table ggg cascade;
-- append only tests
create table foz (i int, d date) with (appendonly = true) distributed by (i)
partition by range (d) (start (date '2001-01-01') end (date '2005-01-01')
every(interval '1 year'));
NOTICE:  CREATE TABLE will create partition "foz_1_prt_1" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_2" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_3" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_4" for table "foz"
insert into foz select i, '2001-01-01'::date + ('1 day'::interval * i) from
generate_series(1, 1000) i;
select count(*) from foz;
 count 
-------
  1000
(1 row)

select count(*) from foz_1_prt_1;
 count 
-------
   364
(1 row)

select min(d), max(d) from foz;
    min     |    max     
------------+------------
 01-02-2001 | 09-28-2003
(1 row)

select min(d), max(d) from foz_1_prt_1;
    min     |    max     
------------+------------
 01-02-2001 | 12-31-2001
(1 row)

select min(d), max(d) from foz_1_prt_2;
    min     |    max     
------------+------------
 01-01-2002 | 12-31-2002
(1 row)

select min(d), max(d) from foz_1_prt_3;
    min     |    max     
------------+------------
 01-01-2003 | 09-28-2003
(1 row)

select min(d), max(d) from foz_1_prt_4;
 min | max 
-----+-----
     | 
(1 row)

drop table foz cascade;
-- copy test
create table foz (i int, d date) distributed by (i)
partition by range (d) (start (date '2001-01-01') end (date '2005-01-01')
every(interval '1 year'));
NOTICE:  CREATE TABLE will create partition "foz_1_prt_1" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_2" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_3" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_4" for table "foz"
COPY foz FROM stdin DELIMITER '|';
select * from foz_1_prt_1;
 i |     d      
---+------------
 1 | 01-02-2001
1389
 2 | 10-10-2001
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487
(2 rows)

select * from foz_1_prt_2;
 i |     d      
---+------------
 3 | 10-30-2002
(1 row)

select * from foz_1_prt_3;
 i |     d      
---+------------
 4 | 01-01-2003
(1 row)

select * from foz_1_prt_4;
 i |     d      
---+------------
 5 | 05-05-2004
(1 row)

-- Check behaviour of key for which there is no partition
COPY foz FROM stdin DELIMITER '|';
ERROR:  no partition for partitioning key
CONTEXT:  COPY foz, line 1: "6|2010-01-01"
drop table foz cascade;
-- Same test with append only
create table foz (i int, d date) with (appendonly = true) distributed by (i)
partition by range (d) (start (date '2001-01-01') end (date '2005-01-01')
every(interval '1 year'));
NOTICE:  CREATE TABLE will create partition "foz_1_prt_1" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_2" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_3" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_4" for table "foz"
COPY foz FROM stdin DELIMITER '|';
select * from foz_1_prt_1;
 i |     d      
---+------------
 2 | 10-10-2001
 1 | 01-02-2001
(2 rows)

select * from foz_1_prt_2;
 i |     d      
---+------------
 3 | 10-30-2002
(1 row)

select * from foz_1_prt_3;
 i |     d      
---+------------
 4 | 01-01-2003
(1 row)

select * from foz_1_prt_4;
 i |     d      
---+------------
 5 | 05-05-2004
(1 row)

-- Check behaviour of key for which there is no partition
COPY foz FROM stdin DELIMITER '|';
ERROR:  no partition for partitioning key
CONTEXT:  COPY foz, line 1: "6|2010-01-01"
drop table foz cascade;
-- complain if create table as select (CTAS)
CREATE TABLE rank1 (id int,
rank int, year date, gender char(1));
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column 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 table rank2 as select * from rank1
DISTRIBUTED BY (id, gender, year)
partition by list (gender)
subpartition by range (year)
subpartition template (
start (date '2001-01-01')
end (date '2006-01-01') every (interval '1 year')) (
partition boys values ('M'),
partition girls values ('F')
);
ERROR:  Cannot create a partitioned table using CREATE TABLE AS SELECT
HINT:  Use CREATE TABLE...LIKE (followed by INSERT...SELECT) instead
-- like is ok
create table rank2 (like rank1)
DISTRIBUTED BY (id, gender, year)
partition by list (gender)
subpartition by range (year)
subpartition template (
start (date '2001-01-01')
end (date '2006-01-01') every (interval '1 year')) (
partition boys values ('M'),
partition girls values ('F')
);
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_boys" for table "rank2"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_boys_2_prt_1" for table "rank2_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_boys_2_prt_2" for table "rank2_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_boys_2_prt_3" for table "rank2_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_boys_2_prt_4" for table "rank2_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_boys_2_prt_5" for table "rank2_1_prt_boys"
1488
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_girls" for table "rank2"
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_girls_2_prt_1" for table "rank2_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_girls_2_prt_2" for table "rank2_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_girls_2_prt_3" for table "rank2_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_girls_2_prt_4" for table "rank2_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank2_1_prt_girls_2_prt_5" for table "rank2_1_prt_girls"
drop table rank1 cascade;
drop table rank2 cascade;
-- alter table testing
create table hhh (a char(1), b date, d char(3))
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01') 
    with (appendonly=true),
partition bb start (date '2008-01-01') end (date '2009-01-01')
    with (appendonly=false)
);
NOTICE:  CREATE TABLE will create partition "hhh_1_prt_aa" for table "hhh"
NOTICE:  CREATE TABLE will create partition "hhh_1_prt_bb" for table "hhh"
-- already exists
alter table hhh add partition aa;
ERROR:  partition "aa" of relation "hhh" already exists
-- no partition spec
alter table hhh add partition cc;
ERROR:  missing boundary specification
-- overlaps
alter table hhh add partition cc start ('2008-01-01') end ('2010-01-01');
ERROR:  new partition overlaps existing partition "bb"
alter table hhh add partition cc end ('2008-01-01');
ERROR:  new partition overlaps existing partition
-- reversed (start > end)
alter table hhh add partition cc start ('2010-01-01') end ('2009-01-01');
ERROR:  START greater than END for partition "cc"
-- works
--alter table hhh add partition cc start ('2009-01-01') end ('2010-01-01');
alter table hhh add partition cc end ('2010-01-01');
NOTICE:  CREATE TABLE will create partition "hhh_1_prt_cc" for table "hhh"
-- works - anonymous partition MPP-3350
alter table hhh add partition end ('2010-02-01');
1528
NOTICE:  CREATE TABLE will create partition "hhh_1_prt_r1244790963" for table "hhh"
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765
-- MPP-3607 - ADD PARTITION with open intervals
create table no_end1 (aa int, bb int) partition by range (bb)
(partition foo start(3));
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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 "no_end1_1_prt_foo" for table "no_end1"
-- fail overlap
alter table no_end1 add partition baz end (4);
ERROR:  new partition overlaps existing partition
-- fail overlap (because prior partition has no end)
alter table no_end1 add partition baz start (5);
ERROR:  new partition overlaps existing partition
-- ok (terminates on foo start)
alter table no_end1 add partition baz start (2);
NOTICE:  CREATE TABLE will create partition "no_end1_1_prt_baz" for table "no_end1"
-- ok (because ends before baz start)
alter table no_end1 add partition baz2 end (1);
NOTICE:  CREATE TABLE will create partition "no_end1_1_prt_baz2" for table "no_end1"
create table no_start1 (aa int, bb int) partition by range (bb)
(partition foo end(3));
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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 "no_start1_1_prt_foo" for table "no_start1"
-- fail overlap (because next partition has no start)
alter table no_start1 add partition baz start (2);
ERROR:  new partition overlaps existing partition
-- fail overlap (because next partition has no start)
alter table no_start1 add partition baz end (1);
ERROR:  new partition overlaps existing partition
-- ok (starts on foo end)
alter table no_start1 add partition baz end (4);
NOTICE:  CREATE TABLE will create partition "no_start1_1_prt_baz" for table "no_start1"
-- ok (because starts after baz end)
alter table no_start1 add partition baz2 start (5);
NOTICE:  CREATE TABLE will create partition "no_start1_1_prt_baz2" for table "no_start1"
select tablename, partitionlevel, parentpartitiontablename,
partitionname, partitionrank, partitionboundary from pg_partitions
where tablename = 'no_start1' or tablename = 'no_end1' 
order by tablename, partitionrank;
 tablename | partitionlevel | parentpartitiontablename | partitionname | partitionrank |        partitionboundary        
-----------+----------------+--------------------------+---------------+---------------+---------------------------------
 no_end1   |              0 |                          | baz2          |             1 | PARTITION baz2  END (1)
 no_end1   |              0 |                          | baz           |             2 | PARTITION baz START (2) END (3)
 no_end1   |              0 |                          | foo           |             3 | PARTITION foo START (3)
 no_start1 |              0 |                          | foo           |             1 | PARTITION foo  END (3)
 no_start1 |              0 |                          | baz           |             2 | PARTITION baz START (3) END (4)
 no_start1 |              0 |                          | baz2          |             3 | PARTITION baz2 START (5)
(6 rows)

drop table no_end1;
drop table no_start1;
-- hash partitions cannot have default partitions
create table jjj (aa int, bb int) 
partition by hash(bb) 
(partition j1, partition j2);
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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 "jjj_1_prt_j1" for table "jjj"
NOTICE:  CREATE TABLE will create partition "jjj_1_prt_j2" for table "jjj"
alter table jjj add default partition;
ERROR:  syntax error at or near ";"
LINE 1: alter table jjj add default partition;
                                             ^
drop table jjj cascade;
-- default partitions cannot have boundary specifications
create table jjj (aa int, bb date) 
partition by range(bb) 
(partition j1 end (date '2008-01-01'), 
partition j2 end (date '2009-01-01'));
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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 "jjj_1_prt_j1" for table "jjj"
NOTICE:  CREATE TABLE will create partition "jjj_1_prt_j2" for table "jjj"
-- must have a name
alter table jjj add default partition;
ERROR:  syntax error at or near ";"
LINE 1: alter table jjj add default partition;
                                             ^
alter table jjj add default partition for (rank(1));
ERROR:  Can only ADD a partition by name
-- cannot have boundary spec
alter table jjj add default partition j3 end (date '2010-01-01');
ERROR:  invalid use of boundary specification for DEFAULT partition "j3" of relation "jjj"
drop table jjj cascade;
-- only one default partition
create table jjj (aa int, bb date) 
partition by range(bb) 
(partition j1 end (date '2008-01-01'), 
partition j2 end (date '2009-01-01'),
default partition j3);
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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 "jjj_1_prt_j3" for table "jjj"
NOTICE:  CREATE TABLE will create partition "jjj_1_prt_j1" for table "jjj"
NOTICE:  CREATE TABLE will create partition "jjj_1_prt_j2" for table "jjj"
alter table jjj add default partition j3 ;
ERROR:  partition "j3" of relation "jjj" already exists
alter table jjj add default partition j4 ;
ERROR:  DEFAULT partition "j3" for relation "jjj" already exists
-- cannot add if have default, must split
alter table jjj add partition j5 end (date '2010-01-01');
ERROR:  cannot add RANGE partition "j5" to relation "jjj" with DEFAULT partition "j3"
HINT:  need to SPLIT partition "j3"
drop table jjj cascade;
alter table hhh alter partition cc set tablespace foo_p;
ERROR:  tablespace "foo_p" does not exist
alter table hhh alter partition aa set tablespace foo_p;
ERROR:  tablespace "foo_p" does not exist
alter table hhh coalesce partition cc;
ERROR:  cannot COALESCE PARTITION for relation "hhh"
alter table hhh coalesce partition aa;
ERROR:  cannot COALESCE PARTITION for relation "hhh"
alter table hhh drop partition cc;
alter table hhh drop partition cc cascade;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh drop partition cc restrict;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh drop partition if exists cc;
NOTICE:  partition "cc" of relation "hhh" does not exist, skipping
-- fail (mpp-3265)
alter table hhh drop partition for (rank(0));
ERROR:  partition for rank 0 of relation "hhh" does not exist
alter table hhh drop partition for (rank(-55));
ERROR:  partition for rank -55 of relation "hhh" does not exist
alter table hhh drop partition for ('2001-01-01');
ERROR:  partition for value ('2001-01-01') of relation "hhh" does not exist
create table hhh_r1 (a char(1), b date, d char(3))
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01') 
             every (interval '1 month')
);
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_1" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_2" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_3" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_4" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_5" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_6" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_7" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_8" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_9" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_10" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_11" for table "hhh_r1"
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_aa_12" for table "hhh_r1"
create table hhh_l1 (a char(1), b date, d char(3))
distributed by (a)
partition by list (b)
(
partition aa values ('2007-01-01'),
partition bb values ('2008-01-01'),
partition cc values ('2009-01-01') 
);
NOTICE:  CREATE TABLE will create partition "hhh_l1_1_prt_aa" for table "hhh_l1"
NOTICE:  CREATE TABLE will create partition "hhh_l1_1_prt_bb" for table "hhh_l1"
NOTICE:  CREATE TABLE will create partition "hhh_l1_1_prt_cc" for table "hhh_l1"
-- must have name or value for list partition
alter table hhh_l1 drop partition;
ERROR:  missing name or value for DROP for relation "hhh_l1"
alter table hhh_l1 drop partition aa;
alter table hhh_l1 drop partition for ('2008-01-01');
NOTICE:  dropped partition "bb" for relation "hhh_l1"
-- if not specified, drop first range partition...
alter table hhh_r1 drop partition for ('2007-04-01');
NOTICE:  dropped partition "aa_4" for relation "hhh_r1"
alter table hhh_r1 drop partition;
NOTICE:  dropped partition "aa_1" for relation "hhh_r1"
alter table hhh_r1 drop partition;
NOTICE:  dropped partition "aa_2" for relation "hhh_r1"
alter table hhh_r1 drop partition;
NOTICE:  dropped partition "aa_3" for relation "hhh_r1"
alter table hhh_r1 drop partition;
NOTICE:  dropped partition "aa_5" for relation "hhh_r1"
alter table hhh_r1 drop partition;
NOTICE:  dropped partition "aa_6" for relation "hhh_r1"
-- more add partition tests
-- start before first partition (fail because start equal end)
alter table hhh_r1 add partition zaa start ('2007-07-01');
ERROR:  new partition overlaps existing partition
-- start before first partition (ok)
alter table hhh_r1 add partition zaa start ('2007-06-01');
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_zaa" for table "hhh_r1"
-- start > last (fail because start equal end)
alter table hhh_r1 add partition bb start ('2008-01-01') end ('2008-01-01') ;
ERROR:  START equal to END for partition "bb"
-- start > last (ok)
alter table hhh_r1 add partition bb start ('2008-01-01') 
end ('2008-02-01') inclusive;
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_bb" for table "hhh_r1"
-- start > last (fail because start == last end inclusive)
alter table hhh_r1 add partition cc start ('2008-02-01') end ('2008-03-01') ;
ERROR:  new partition overlaps existing partition "bb"
-- start > last (ok [and leave a gap])
alter table hhh_r1 add partition cc start ('2008-04-01') end ('2008-05-01') ;
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_cc" for table "hhh_r1"
-- overlap (fail)
alter table hhh_r1 add partition dd start ('2008-01-01') end ('2008-05-01') ;
ERROR:  new partition overlaps existing partition "bb"
-- new partition in "gap" (ok)
alter table hhh_r1 add partition dd start ('2008-03-01') end ('2008-04-01') ;
NOTICE:  CREATE TABLE will create partition "hhh_r1_1_prt_dd" for table "hhh_r1"
-- overlap all partitions (fail)
alter table hhh_r1 add partition ee start ('2006-01-01') end ('2009-01-01') ;
ERROR:  new partition overlaps existing partition
-- start before first partition (fail because end in "gap" [and overlaps])
alter table hhh_r1 add partition yaa start ('2007-05-01') end ('2007-07-01');
ERROR:  new partition overlaps existing partition "aa_7"
-- start before first partition (fail )
alter table hhh_r1 add partition yaa start ('2007-05-01') 
end ('2007-10-01') inclusive;
ERROR:  new partition overlaps existing partition "aa_10"
-- start before first partition (fail because end overlaps)
alter table hhh_r1 add partition yaa start ('2007-05-01') 
end ('2007-10-01') exclusive;
ERROR:  new partition overlaps existing partition "aa_10"
drop table hhh_r1 cascade;
drop table hhh_l1 cascade;
--  the documentation example, rewritten with EVERY in a template
--  and also with a default partition
CREATE TABLE rank (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')
end (date '2006-01-01') every (interval '1 year')) (
partition boys values ('M'),
partition girls values ('F'),
default partition neuter
);
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys" for table "rank"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_1" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_2" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_3" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_4" for table "rank_1_prt_boys"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_boys_2_prt_5" for table "rank_1_prt_boys"
1766
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls" for table "rank"
1767 1768 1769 1770 1771
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_1" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_2" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_3" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_4" for table "rank_1_prt_girls"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_5" for table "rank_1_prt_girls"
1772
NOTICE:  CREATE TABLE will create partition "rank_1_prt_neuter" for table "rank"
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810
NOTICE:  CREATE TABLE will create partition "rank_1_prt_neuter_2_prt_1" for table "rank_1_prt_neuter"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_neuter_2_prt_2" for table "rank_1_prt_neuter"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_neuter_2_prt_3" for table "rank_1_prt_neuter"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_neuter_2_prt_4" for table "rank_1_prt_neuter"
NOTICE:  CREATE TABLE will create partition "rank_1_prt_neuter_2_prt_5" for table "rank_1_prt_neuter"
insert into rank values (1, 1, date '2001-01-15', 'M');
insert into rank values (2, 1, date '2002-02-15', 'M');
insert into rank values (3, 1, date '2003-03-15', 'M');
insert into rank values (4, 1, date '2004-04-15', 'M');
insert into rank values (5, 1, date '2005-05-15', 'M');
insert into rank values (6, 1, date '2001-01-15', 'F');
insert into rank values (7, 1, date '2002-02-15', 'F');
insert into rank values (8, 1, date '2003-03-15', 'F');
insert into rank values (9, 1, date '2004-04-15', 'F');
insert into rank values (10, 1, date '2005-05-15', 'F');
select * from rank ;
 id | rank |    year    | gender 
----+------+------------+--------
  1 |    1 | 01-15-2001 | M
  3 |    1 | 03-15-2003 | M
  4 |    1 | 04-15-2004 | M
  6 |    1 | 01-15-2001 | F
  8 |    1 | 03-15-2003 | F
  9 |    1 | 04-15-2004 | F
  2 |    1 | 02-15-2002 | M
  5 |    1 | 05-15-2005 | M
  7 |    1 | 02-15-2002 | F
 10 |    1 | 05-15-2005 | F
(10 rows)

alter table rank DROP partition boys restrict;
NOTICE:  dropped partition "boys" for relation "rank" and its children
select * from rank ;
 id | rank |    year    | gender 
----+------+------------+--------
  6 |    1 | 01-15-2001 | F
  8 |    1 | 03-15-2003 | F
  9 |    1 | 04-15-2004 | F
1811 1812
  7 |    1 | 02-15-2002 | F
 10 |    1 | 05-15-2005 | F
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167
(5 rows)

-- MPP-3722: complain if for(value) matches the default partition 
alter table rank truncate partition for('N');
ERROR:  FOR expression matches DEFAULT partition "neuter" of relation "rank"
HINT:  FOR expression may only specify a non-default partition in this context.
alter table rank DROP partition for('N');
ERROR:  FOR expression matches DEFAULT partition "neuter" of relation "rank"
HINT:  FOR expression may only specify a non-default partition in this context.
alter table rank DROP partition if exists for('N');
ERROR:  FOR expression matches DEFAULT partition "neuter" of relation "rank"
HINT:  FOR expression may only specify a non-default partition in this context.
alter table rank DROP default partition if exists ;
NOTICE:  dropped partition "neuter" for relation "rank" and its children
-- can't drop the final partition - must drop the table
alter table rank DROP partition girls;
ERROR:  cannot drop partition "girls" of relation "rank" -- only one remains
HINT:  Use DROP TABLE "rank" to remove the table and the final partition
-- MPP-4011: make FOR(value) work
alter table rank alter partition for ('F') add default partition def1;
NOTICE:  CREATE TABLE will create partition "rank_1_prt_girls_2_prt_def1" for table "rank_1_prt_girls"
alter table rank alter partition for ('F') 
truncate partition for ('2010-10-10');
ERROR:  FOR expression matches DEFAULT partition "def1" of partition "girls" of relation "rank"
HINT:  FOR expression may only specify a non-default partition in this context.
alter table rank truncate partition for ('F');
NOTICE:  truncated partition "girls" for relation "rank" and its children
drop table rank cascade;
alter table hhh exchange partition cc with table nosuchtable with validation;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh exchange partition cc with table nosuchtable without validation;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh exchange partition aa with table nosuchtable with validation;
ERROR:  relation "nosuchtable" does not exist
alter table hhh exchange partition aa with table nosuchtable without validation;
ERROR:  relation "nosuchtable" does not exist
alter table hhh merge partition cc, partition dd;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh merge partition cc, partition dd into partition ee;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh merge partition aa, partition dd into partition ee;
ERROR:  partition "dd" of relation "hhh" does not exist
alter table hhh modify partition cc add values ('a');
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh modify partition cc drop values ('a');
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh modify partition aa add values ('a');
ERROR:  invalid use of LIST boundary specification in partition "aa" of type RANGE
alter table hhh modify partition aa drop values ('a');
ERROR:  invalid use of LIST boundary specification in partition "aa" of type RANGE
create table mmm_r1 (a char(1), b date, d char(3))
distributed by (a)
partition by range (b)
(
partition aa start (date '2007-01-01') end (date '2008-01-01')
             every (interval '1 month')
);
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_1" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_2" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_3" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_4" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_5" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_6" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_7" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_8" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_9" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_10" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_11" for table "mmm_r1"
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_aa_12" for table "mmm_r1"
create table mmm_l1 (a char(1), b char(1), d char(3))
distributed by (a)
partition by list (b)
(
partition aa values ('a', 'b', 'c'),
partition bb values ('d', 'e', 'f'),
partition cc values ('g', 'h', 'i')
);
NOTICE:  CREATE TABLE will create partition "mmm_l1_1_prt_aa" for table "mmm_l1"
NOTICE:  CREATE TABLE will create partition "mmm_l1_1_prt_bb" for table "mmm_l1"
NOTICE:  CREATE TABLE will create partition "mmm_l1_1_prt_cc" for table "mmm_l1"
alter table mmm_r1 drop partition for ('2007-03-01');
NOTICE:  dropped partition "aa_3" for relation "mmm_r1"
-- ok
alter table mmm_r1 add partition bb START ('2007-03-03') END ('2007-03-20');
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_bb" for table "mmm_r1"
-- fail
alter table mmm_r1 modify partition for (rank(-55)) start ('2007-03-02');
ERROR:  partition for rank -55 of relation "mmm_r1" does not exist
alter table mmm_r1 modify partition for ('2001-01-01') start ('2007-03-02');
ERROR:  partition for value ('2001-01-01') of relation "mmm_r1" does not exist
alter table mmm_r1 modify partition bb start ('2006-03-02');
ERROR:  cannot MODIFY RANGE partition "bb" for relation "mmm_r1" -- would overlap existing partition "aa_2"
alter table mmm_r1 modify partition bb start ('2011-03-02');
ERROR:  START greater than END for partition "bb"
alter table mmm_r1 modify partition bb end ('2006-03-02');
ERROR:  START greater than END for partition "bb"
alter table mmm_r1 modify partition bb end ('2011-03-02');
ERROR:  cannot MODIFY RANGE partition "bb" for relation "mmm_r1" -- would overlap existing partition "aa_4"
alter table mmm_r1 modify partition bb add values ('2011-03-02');
ERROR:  invalid use of LIST boundary specification in partition "bb" of type RANGE
alter table mmm_r1 modify partition bb drop values ('2011-03-02');
ERROR:  invalid use of LIST boundary specification in partition "bb" of type RANGE
--ok
alter table mmm_r1 modify partition bb START ('2007-03-02') END ('2007-03-22');
alter table mmm_r1 modify partition bb START ('2007-03-01') END ('2007-03-31');
alter table mmm_r1 modify partition bb START ('2007-03-02') END ('2007-03-22');
-- with default
alter table mmm_r1 add default partition def1;
NOTICE:  CREATE TABLE will create partition "mmm_r1_1_prt_def1" for table "mmm_r1"
-- now fail
alter table mmm_r1 modify partition bb START ('2007-03-01') END ('2007-03-31');
ERROR:  cannot MODIFY RANGE partition "bb" for relation "mmm_r1" to extend range -- would overlap DEFAULT partition "def1"
HINT:  need to SPLIT partition "def1"
-- still ok to reduce range
alter table mmm_r1 modify partition bb START ('2007-03-09') END ('2007-03-10');
-- fail
alter table mmm_l1 modify partition for (rank(1)) drop values ('k');
ERROR:  cannot find partition by RANK -- relation "mmm_l1" is LIST partitioned
alter table mmm_l1 modify partition for ('j') drop values ('k');
ERROR:  partition for value ('j') of relation "mmm_l1" does not exist
alter table mmm_l1 modify partition for ('a') drop values ('k');
ERROR:  cannot MODIFY LIST partition "aa" for relation "mmm_l1" -- DROP value not found
alter table mmm_l1 modify partition for ('a') drop values ('e');
ERROR:  cannot MODIFY LIST partition "aa" for relation "mmm_l1" -- found DROP value in partition "bb"
alter table mmm_l1 modify partition for ('a') add values ('e');
ERROR:  cannot MODIFY LIST partition "aa" for relation "mmm_l1" -- would overlap existing partition "bb"
alter table mmm_l1 modify partition for ('a') START ('2007-03-09') ;
ERROR:  invalid use of RANGE boundary specification in partition "aa" of type LIST
--ok
alter table mmm_l1 modify partition for ('a') drop values ('b');
alter table mmm_l1 modify partition for ('a') add values ('z');
-- with default
alter table mmm_l1 add default partition def1;
NOTICE:  CREATE TABLE will create partition "mmm_l1_1_prt_def1" for table "mmm_l1"
-- ok
alter table mmm_l1 modify partition for ('a') drop values ('c');
-- now fail
alter table mmm_l1 modify partition for ('a') add values ('y');
ERROR:  cannot MODIFY LIST partition "aa" for relation "mmm_l1" to ADD values -- would overlap DEFAULT partition "def1"
HINT:  need to SPLIT partition "def1"
-- XXX XXX: add some data 
drop table mmm_r1 cascade;
drop table mmm_l1 cascade;
alter table hhh rename partition cc to aa;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh rename partition aa to aa;
ERROR:  partition "aa" of relation "hhh" already exists
alter table hhh rename partition aa to "funky fresh";
alter table hhh rename partition "funky fresh" to aa;
-- use FOR PARTITION VALUE (with implicate date conversion)
alter table hhh rename partition for ('2007-01-01') to "funky fresh";
NOTICE:  renamed partition "aa" to "funky fresh" for relation "hhh"
alter table hhh rename partition for ('2007-01-01') to aa;
NOTICE:  renamed partition "funky fresh" to "aa" for relation "hhh"
alter table hhh set subpartition template ();
ERROR:  relation "hhh" does not have a level 1 subpartition template specification
alter table hhh split partition cc at ('a');
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh split partition cc at ('a') into (partition gg, partition hh);
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh split partition aa at ('a');
ERROR:  invalid input syntax for type date: "a"
alter table hhh truncate partition cc;
ERROR:  partition "cc" of relation "hhh" does not exist
alter table hhh truncate partition aa;
insert into hhh values('a', date '2007-01-02', 'b');
insert into hhh values('a', date '2007-02-01', 'b');
insert into hhh values('a', date '2007-03-01', 'b');
insert into hhh values('a', date '2007-04-01', 'b');
insert into hhh values('a', date '2007-05-01', 'b');
insert into hhh values('a', date '2007-06-01', 'b');
insert into hhh values('a', date '2007-07-01', 'b');
insert into hhh values('a', date '2007-08-01', 'b');
insert into hhh values('a', date '2007-09-01', 'b');
insert into hhh values('a', date '2007-10-01', 'b');
insert into hhh values('a', date '2007-11-01', 'b');
insert into hhh values('a', date '2007-12-01', 'b');
insert into hhh values('a', date '2008-01-02', 'b');
insert into hhh values('a', date '2008-02-01', 'b');
insert into hhh values('a', date '2008-03-01', 'b');
insert into hhh values('a', date '2008-04-01', 'b');
insert into hhh values('a', date '2008-05-01', 'b');
insert into hhh values('a', date '2008-06-01', 'b');
insert into hhh values('a', date '2008-07-01', 'b');
insert into hhh values('a', date '2008-08-01', 'b');
insert into hhh values('a', date '2008-09-01', 'b');
insert into hhh values('a', date '2008-10-01', 'b');
insert into hhh values('a', date '2008-11-01', 'b');
insert into hhh values('a', date '2008-12-01', 'b');
select * from hhh;
 a |     b      |  d  
---+------------+-----
 a | 01-02-2007 | b  
 a | 02-01-2007 | b  
 a | 03-01-2007 | b  
 a | 04-01-2007 | b  
 a | 05-01-2007 | b  
 a | 06-01-2007 | b  
 a | 07-01-2007 | b  
 a | 08-01-2007 | b  
 a | 09-01-2007 | b  
 a | 10-01-2007 | b  
 a | 11-01-2007 | b  
 a | 12-01-2007 | b  
 a | 01-02-2008 | b  
 a | 02-01-2008 | b  
 a | 03-01-2008 | b  
 a | 04-01-2008 | b  
 a | 05-01-2008 | b  
 a | 06-01-2008 | b  
 a | 07-01-2008 | b  
 a | 08-01-2008 | b  
 a | 09-01-2008 | b  
 a | 10-01-2008 | b  
 a | 11-01-2008 | b  
 a | 12-01-2008 | b  
(24 rows)

alter table hhh truncate partition aa;
select * from hhh;
 a |     b      |  d  
---+------------+-----
 a | 01-02-2008 | b  
 a | 02-01-2008 | b  
 a | 03-01-2008 | b  
 a | 04-01-2008 | b  
 a | 05-01-2008 | b  
 a | 06-01-2008 | b  
 a | 07-01-2008 | b  
 a | 08-01-2008 | b  
 a | 09-01-2008 | b  
 a | 10-01-2008 | b  
 a | 11-01-2008 | b  
 a | 12-01-2008 | b  
(12 rows)

alter table hhh truncate partition bb;
select * from hhh;
 a | b | d 
---+---+---
(0 rows)

insert into hhh values('a', date '2007-01-02', 'b');
insert into hhh values('a', date '2007-02-01', 'b');
insert into hhh values('a', date '2007-03-01', 'b');
insert into hhh values('a', date '2007-04-01', 'b');
insert into hhh values('a', date '2007-05-01', 'b');
insert into hhh values('a', date '2007-06-01', 'b');
insert into hhh values('a', date '2007-07-01', 'b');
insert into hhh values('a', date '2007-08-01', 'b');
insert into hhh values('a', date '2007-09-01', 'b');
insert into hhh values('a', date '2007-10-01', 'b');
insert into hhh values('a', date '2007-11-01', 'b');
insert into hhh values('a', date '2007-12-01', 'b');
insert into hhh values('a', date '2008-01-02', 'b');
insert into hhh values('a', date '2008-02-01', 'b');
insert into hhh values('a', date '2008-03-01', 'b');
insert into hhh values('a', date '2008-04-01', 'b');
insert into hhh values('a', date '2008-05-01', 'b');
insert into hhh values('a', date '2008-06-01', 'b');
insert into hhh values('a', date '2008-07-01', 'b');
insert into hhh values('a', date '2008-08-01', 'b');
insert into hhh values('a', date '2008-09-01', 'b');
insert into hhh values('a', date '2008-10-01', 'b');
insert into hhh values('a', date '2008-11-01', 'b');
insert into hhh values('a', date '2008-12-01', 'b');
select * from hhh;
 a |     b      |  d  
---+------------+-----
 a | 01-02-2007 | b  
 a | 02-01-2007 | b  
 a | 03-01-2007 | b  
 a | 04-01-2007 | b  
 a | 05-01-2007 | b  
 a | 06-01-2007 | b  
 a | 07-01-2007 | b  
 a | 08-01-2007 | b  
 a | 09-01-2007 | b  
 a | 10-01-2007 | b  
 a | 11-01-2007 | b  
 a | 12-01-2007 | b  
 a | 01-02-2008 | b  
 a | 02-01-2008 | b  
 a | 03-01-2008 | b  
 a | 04-01-2008 | b  
 a | 05-01-2008 | b  
 a | 06-01-2008 | b  
 a | 07-01-2008 | b  
 a | 08-01-2008 | b  
 a | 09-01-2008 | b  
 a | 10-01-2008 | b  
 a | 11-01-2008 | b  
 a | 12-01-2008 | b  
(24 rows)

-- truncate child partitions recursively
truncate table hhh;
select * from hhh;
 a | b | d 
---+---+---
(0 rows)

drop table hhh cascade;
-- default partitions
-- hash partitions cannot have default partitions
create table jjj (aa int, bb int) 
partition by hash(bb) 
(partition j1, partition j2, default partition j3);
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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.
ERROR:  invalid use of DEFAULT partition for partition "j3" of type HASH
LINE 3: (partition j1, partition j2, default partition j3);
                                     ^
-- default partitions cannot have boundary specifications
create table jjj (aa int, bb date) 
partition by range(bb) 
(partition j1 end (date '2008-01-01'), 
partition j2 end (date '2009-01-01'), 
default partition j3 end (date '2010-01-01'));
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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.
ERROR:  invalid use of boundary specification for DEFAULT partition "j3"
LINE 5: default partition j3 end (date '2010-01-01'));
        ^
-- more than one default partition
create table jjj (aa int, bb date) 
partition by range(bb) 
(partition j1 end (date '2008-01-01'), 
partition j2 end (date '2009-01-01'), 
default partition j3,
default partition j4);
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'aa' 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.
ERROR:  multiple default partitions are not allowed
LINE 6: default partition j4);
        ^
-- check default
create table foz (i int, d date) distributed by (i)
partition by range (d) 
(
 default partition dsf,
 partition foo start (date '2001-01-01') end (date '2005-01-01')
               every(interval '1 year')
);
NOTICE:  CREATE TABLE will create partition "foz_1_prt_dsf" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_foo_1" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_foo_2" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_foo_3" for table "foz"
NOTICE:  CREATE TABLE will create partition "foz_1_prt_foo_4" for table "foz"
insert into foz values(1, '2003-04-01');
insert into foz values(2, '2010-04-01');
select * from foz;
 i |     d      
---+------------
 1 | 04-01-2003
2168
 2 | 04-01-2010
2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189
(2 rows)

select * from foz_1_prt_dsf;
 i |     d      
---+------------
 2 | 04-01-2010
(1 row)

drop table foz cascade;
-- check for out of order partition definitions. We should order these correctly
-- and determine the appropriate boundaries.
create table d (i int, j int) distributed by (i) partition by range(j)
( start (10), start(5), start(50) end(60));
NOTICE:  CREATE TABLE will create partition "d_1_prt_1" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_2" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_3" for table "d"
insert into d values(1, 5);
insert into d values(1, 10);
insert into d values(1, 11);
insert into d values(1, 55);
insert into d values(1, 70);
2190
ERROR:  no partition for partitioning key  (seg0 xzhangmac:40000 pid=94563)
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272
select * from d;
 i | j  
---+----
 1 |  5
 1 | 10
 1 | 11
 1 | 55
(4 rows)

select * from d_1_prt_1;
 i | j 
---+---
 1 | 5
(1 row)

select * from d_1_prt_2;
 i | j  
---+----
 1 | 10
 1 | 11
(2 rows)

select * from d_1_prt_3;
 i | j  
---+----
 1 | 55
(1 row)

drop table d cascade;
-- check for NULL support
-- hash
create table d (i int, j int) partition by hash(j) partitions 4;
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 "d_1_prt_1" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_2" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_3" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_4" for table "d"
insert into d values(1, NULL);
insert into d values(NULL, NULL);
drop table d cascade;
-- list
create table d (i int, j int) partition by list(j)
(partition a values(1, 2, NULL),
 partition b values(3, 4)
);
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 "d_1_prt_a" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_b" for table "d"
insert into d values(1, 1);
insert into d values(1, 2);
insert into d values(1, NULL);
insert into d values(1, 3);
insert into d values(1, 4);
select * from d_1_prt_a;
 i | j 
---+---
 1 | 1
 1 | 2
 1 |  
(3 rows)

select * from d_1_prt_b;
 i | j 
---+---
 1 | 3
 1 | 4
(2 rows)

drop table d cascade;
--range
-- Reject NULL values
create table d (i int,  j int) partition by range(j)
(partition a start (1) end(10), partition b start(11) 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 "d_1_prt_a" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_b" for table "d"
insert into d values (1, 1);
insert into d values (1, 2);
insert into d values (1, NULL);
2273
ERROR:  no partition for partitioning key  (seg0 xzhangmac:40000 pid=94563)
2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306
drop table  d cascade;
-- allow NULLs into the default partition
create table d (i int,  j int) partition by range(j)
(partition a start (1) end(10), partition b start(11) end(20),
default partition abc);
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 "d_1_prt_abc" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_a" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_b" for table "d"
insert into d values (1, 1);
insert into d values (1, 2);
insert into d values (1, NULL);
select * from d_1_prt_abc;
 i | j 
---+---
 1 |  
(1 row)

drop table  d cascade;
-- multicolumn list support
create table d (a int, b int, c int) distributed by (a) 
partition by list(b, c)
(partition a values(('1', '2'), ('3', '4')),
 partition b values(('100', '20')),
 partition c values(('1000', '1001'), ('1001', '1002'), ('1003', '1004')));
NOTICE:  CREATE TABLE will create partition "d_1_prt_a" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_b" for table "d"
NOTICE:  CREATE TABLE will create partition "d_1_prt_c" for table "d"
insert into d values(1, 1, 2);
insert into d values(1, 3, 4);
insert into d values(1, 100, 20);
insert into d values(1, 100, 2000);
2307
ERROR:  no partition for partitioning key  (seg0 xzhangmac:40000 pid=94563)
2308 2309
insert into d values(1, '1000', '1001'), (1, '1001', '1002'), (1, '1003', '1004');
insert into d values(1, 100, NULL);
2310
ERROR:  no partition for partitioning key  (seg0 xzhangmac:40000 pid=94563)
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346
select * from d_1_prt_a;
 a | b | c 
---+---+---
 1 | 1 | 2
 1 | 3 | 4
(2 rows)

select * from d_1_prt_b;
 a |  b  | c  
---+-----+----
 1 | 100 | 20
(1 row)

select * from d_1_prt_c;
 a |  b   |  c   
---+------+------
 1 | 1000 | 1001
 1 | 1001 | 1002
 1 | 1003 | 1004
(3 rows)

drop table d cascade;
-- test multi value range partitioning
create table b (i int, j date) distributed by (i)
partition by range (i, j)
(start(1, '2008-01-01') end (10, '2009-01-01'),
 start(1, '2009-01-01') end(15, '2010-01-01'),
 start(15, '2010-01-01') end (30, '2011-01-01'),
 start(1, '2011-01-01') end (100, '2012-01-01')
);
ERROR:  too many columns for RANGE partition -- only one column is allowed.
LINE 2: partition by range (i, j)
                     ^
-- should work
insert into b values(1, '2008-06-11');
ERROR:  relation "b" does not exist
2347 2348
LINE 1: insert into b values(1, '2008-06-11');
                    ^
2349 2350
insert into b values(11, '2009-08-24');
ERROR:  relation "b" does not exist
2351 2352
LINE 1: insert into b values(11, '2009-08-24');
                    ^
2353 2354
insert into b values(25, '2010-01-22');
ERROR:  relation "b" does not exist
2355 2356
LINE 1: insert into b values(25, '2010-01-22');
                    ^
2357 2358
insert into b values(90, '2011-05-04');
ERROR:  relation "b" does not exist
2359 2360
LINE 1: insert into b values(90, '2011-05-04');
                    ^
2361 2362 2363
-- shouldn't work
insert into b values(1, '2019-01-01');
ERROR:  relation "b" does not exist
2364 2365
LINE 1: insert into b values(1, '2019-01-01');
                    ^
2366 2367
insert into b values(91, '2008-05-05');
ERROR:  relation "b" does not exist
2368 2369
LINE 1: insert into b values(91, '2008-05-05');
                    ^
2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406
 
select * from b_1_prt_1;
ERROR:  relation "b_1_prt_1" does not exist
LINE 1: select * from b_1_prt_1;
                      ^
select * from b_1_prt_2;
ERROR:  relation "b_1_prt_2" does not exist
LINE 1: select * from b_1_prt_2;
                      ^
select * from b_1_prt_3;
ERROR:  relation "b_1_prt_3" does not exist
LINE 1: select * from b_1_prt_3;
                      ^
select * from b_1_prt_4;
ERROR:  relation "b_1_prt_4" does not exist
LINE 1: select * from b_1_prt_4;
                      ^
drop table b;
ERROR:  table "b" does not exist
-- try some different combinations
create table b (i int, n numeric(20, 2), t timestamp, s text)
distributed by (i)
partition by range(n, t, s)
(
start(2000.99, '2007-01-01 00:00:00', 'AAA')
  end (4000.95, '2007-02-02 15:00:00', 'BBB'),
start(2000.99, '2007-01-01 00:00:00', 'BBB')
  end (4000.95, '2007-02-02 16:00:00', 'CCC'),
start(4000.95, '2007-01-01 00:00:00', 'AAA')
  end (7000.95, '2007-02-02 15:00:00', 'BBB')
);
ERROR:  too many columns for RANGE partition -- only one column is allowed.
LINE 3: partition by range(n, t, s)
                     ^
-- should work
insert into b values(1, 2000.99, '2007-01-01 00:00:00', 'AAA');
ERROR:  relation "b" does not exist
2407 2408
LINE 1: insert into b values(1, 2000.99, '2007-01-01 00:00:00', 'AAA...
                    ^
2409 2410
insert into b values(2, 2000.99, '2007-01-01 00:00:00', 'BBB');
ERROR:  relation "b" does not exist
2411 2412
LINE 1: insert into b values(2, 2000.99, '2007-01-01 00:00:00', 'BBB...
                    ^
2413 2414
insert into b values(3, 4000.95, '2007-01-01 00:00:00', 'AAA');
ERROR:  relation "b" does not exist
2415 2416
LINE 1: insert into b values(3, 4000.95, '2007-01-01 00:00:00', 'AAA...
                    ^
2417 2418
insert into b values(6, 3000, '2007-02-02 15:30:00', 'BBC');
ERROR:  relation "b" does not exist
2419 2420
LINE 1: insert into b values(6, 3000, '2007-02-02 15:30:00', 'BBC');
                    ^
2421 2422
insert into b values(6, 3000, '2007-02-02 15:30:00', 'CC');
ERROR:  relation "b" does not exist
2423 2424
LINE 1: insert into b values(6, 3000, '2007-02-02 15:30:00', 'CC');
                    ^
2425 2426 2427
insert into b values(6, 3000, '2007-02-02 16:00:00'::timestamp - 
					'1 second'::interval, 'BBZZZZZZZZZZ');
ERROR:  relation "b" does not exist
2428 2429
LINE 1: insert into b values(6, 3000, '2007-02-02 16:00:00'::timesta...
                    ^
2430 2431 2432
-- should fail
insert into b values(6, 3000, '2007-02-02 15:30:00', 'CCCCCCC');
ERROR:  relation "b" does not exist
2433 2434
LINE 1: insert into b values(6, 3000, '2007-02-02 15:30:00', 'CCCCCC...
                    ^
2435 2436
insert into b values(4, 5000, '2007-01-01 12:00:00', 'BCC');
ERROR:  relation "b" does not exist
2437 2438
LINE 1: insert into b values(4, 5000, '2007-01-01 12:00:00', 'BCC');
                    ^
2439 2440
insert into b values(5, 8000, '2007-01-01 12:00:00', 'ZZZ');
ERROR:  relation "b" does not exist
2441 2442
LINE 1: insert into b values(5, 8000, '2007-01-01 12:00:00', 'ZZZ');
                    ^
2443 2444
insert into b values(6, 3000, '2007-02-02 16:00:00', 'ABZZZZZZZZZZ');
ERROR:  relation "b" does not exist
2445 2446
LINE 1: insert into b values(6, 3000, '2007-02-02 16:00:00', 'ABZZZZ...
                    ^
2447 2448
insert into b values(6, 1000, '2007-02-02 16:00:00', 'ABZZZZZZZZZZ');
ERROR:  relation "b" does not exist
2449 2450
LINE 1: insert into b values(6, 1000, '2007-02-02 16:00:00', 'ABZZZZ...
                    ^
2451 2452
insert into b values(6, 3000, '2006-02-02 16:00:00', 'ABZZZZZZZZZZ');
ERROR:  relation "b" does not exist
2453 2454
LINE 1: insert into b values(6, 3000, '2006-02-02 16:00:00', 'ABZZZZ...
                    ^
2455 2456
insert into b values(6, 3000, '2007-02-02 00:00:00', 'A');
ERROR:  relation "b" does not exist
2457 2458
LINE 1: insert into b values(6, 3000, '2007-02-02 00:00:00', 'A');
                    ^
2459 2460 2461
-- NULL tests
insert into b default values;
ERROR:  relation "b" does not exist
2462 2463
LINE 1: insert into b default values;
                    ^
2464 2465
insert into b values(6, 3000, '2007-01-01 12:00:00', NULL);
ERROR:  relation "b" does not exist
2466 2467
LINE 1: insert into b values(6, 3000, '2007-01-01 12:00:00', NULL);
                    ^
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483
drop table b;
ERROR:  table "b" does not exist
-- check that we detect subpartitions partitioning a column that is already
-- a partitioning target
create table a (i int, b int)
distributed by (i)
partition by range (i)
subpartition by hash(b) subpartitions 3,
subpartition by hash(b) subpartitions 2
(start(1) end(100),
 start(100) end(1000)
);
NOTICE:  CREATE TABLE will create partition "a_1_prt_1" for table "a"
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_1" for table "a_1_prt_1"
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_1_3_prt_1" for table "a_1_prt_1_2_prt_1"
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_1_3_prt_2" for table "a_1_prt_1_2_prt_1"
2484
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_2" for table "a_1_prt_1"
2485 2486
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_2_3_prt_1" for table "a_1_prt_1_2_prt_2"
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_2_3_prt_2" for table "a_1_prt_1_2_prt_2"
2487
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_3" for table "a_1_prt_1"
2488 2489
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_3_3_prt_1" for table "a_1_prt_1_2_prt_3"
NOTICE:  CREATE TABLE will create partition "a_1_prt_1_2_prt_3_3_prt_2" for table "a_1_prt_1_2_prt_3"
2490
NOTICE:  CREATE TABLE will create partition "a_1_prt_2" for table "a"
2491 2492 2493
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_1" for table "a_1_prt_2"
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_1_3_prt_1" for table "a_1_prt_2_2_prt_1"
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_1_3_prt_2" for table "a_1_prt_2_2_prt_1"
2494
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_2" for table "a_1_prt_2"
2495 2496
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_2_3_prt_1" for table "a_1_prt_2_2_prt_2"
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_2_3_prt_2" for table "a_1_prt_2_2_prt_2"
2497
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_3" for table "a_1_prt_2"
2498 2499 2500 2501 2502
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_3_3_prt_1" for table "a_1_prt_2_2_prt_3"
NOTICE:  CREATE TABLE will create partition "a_1_prt_2_2_prt_3_3_prt_2" for table "a_1_prt_2_2_prt_3"
-- MPP-3988: allow same column in multiple partitioning keys at
-- different levels -- so this is legal again...
drop table if exists a;
2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542
-- TEST: make sure GPOPT (aka pivotal query optimizer) fall back to legacy query optimizer 
--       for queries with partition elimination over FULL OUTER JOIN
--       between partitioned tables.
-- SETUP
-- start_ignore
drop table if exists s1;
NOTICE:  table "s1" does not exist, skipping
drop table if exists s2;
NOTICE:  table "s2" does not exist, skipping
-- setup two partitioned tables s1 and s2
create table s1 (d1 int, p1 int)
distributed by (d1)
partition by list (p1)
(
  values (0),
  values (1));
NOTICE:  CREATE TABLE will create partition "s1_1_prt_1" for table "s1"
NOTICE:  CREATE TABLE will create partition "s1_1_prt_2" for table "s1"
create table s2 (d2 int, p2 int)
distributed by (d2)
partition by list (p2)
(
  values (0),
  values (1));
NOTICE:  CREATE TABLE will create partition "s2_1_prt_1" for table "s2"
NOTICE:  CREATE TABLE will create partition "s2_1_prt_2" for table "s2"
-- end_ignore
-- VERIFY
-- expect GPOPT fall back to legacy query optimizer
-- since GPOPT don't support partition elimination through full outer joins
select * from s1 full outer join s2 on s1.d1 = s2.d2 and s1.p1 = s2.p2 where s1.p1 = 1;
 d1 | p1 | d2 | p2 
----+----+----+----
(0 rows)

-- CLEANUP
-- start_ignore
drop table if exists s1;
drop table if exists s2;
-- end_ignore
2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085
create table mpp_2914A(id int,  buyDate date, kind char(1))
DISTRIBUTED BY (id)
partition by list (kind) 
subpartition by range(buyDate) 
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')
)
(
        partition auction  values('a','A'),
        partition buyItNow values('b', 'B'),
        default partition catchall
);
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_auction" for table "mpp_2914a"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_auction_2_prt_1" for table "mpp_2914a_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_auction_2_prt_2" for table "mpp_2914a_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_auction_2_prt_3" for table "mpp_2914a_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_auction_2_prt_4" for table "mpp_2914a_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_auction_2_prt_5" for table "mpp_2914a_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_buyitnow" for table "mpp_2914a"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_buyitnow_2_prt_1" for table "mpp_2914a_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_buyitnow_2_prt_2" for table "mpp_2914a_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_buyitnow_2_prt_3" for table "mpp_2914a_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_buyitnow_2_prt_4" for table "mpp_2914a_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_buyitnow_2_prt_5" for table "mpp_2914a_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_catchall" for table "mpp_2914a"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_catchall_2_prt_1" for table "mpp_2914a_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_catchall_2_prt_2" for table "mpp_2914a_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_catchall_2_prt_3" for table "mpp_2914a_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_catchall_2_prt_4" for table "mpp_2914a_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914a_1_prt_catchall_2_prt_5" for table "mpp_2914a_1_prt_catchall"
select count(*) from mpp_2914A;
 count 
-------
     0
(1 row)

\d mpp_2914a*
      Table "public.mpp_2914a"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Number of child tables: 3 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (kind)

Table "public.mpp_2914a_1_prt_auction"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914a
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (buydate)

Table "public.mpp_2914a_1_prt_auction_2_prt_1"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_auction_2_prt_1_check" CHECK (buydate >= '01-01-2001'::date AND buydate < '01-01-2002'::date)
    "mpp_2914a_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914a_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914a_1_prt_auction_2_prt_2"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_auction_2_prt_2_check" CHECK (buydate >= '01-01-2002'::date AND buydate < '01-01-2003'::date)
    "mpp_2914a_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914a_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914a_1_prt_auction_2_prt_3"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_auction_2_prt_3_check" CHECK (buydate >= '01-01-2003'::date AND buydate < '01-01-2004'::date)
    "mpp_2914a_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914a_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914a_1_prt_auction_2_prt_4"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_auction_2_prt_4_check" CHECK (buydate >= '01-01-2004'::date AND buydate < '01-01-2005'::date)
    "mpp_2914a_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914a_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914a_1_prt_auction_2_prt_5"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_auction_2_prt_5_check" CHECK (buydate >= '01-01-2005'::date)
    "mpp_2914a_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914a_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914a_1_prt_buyitnow"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914a
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (buydate)

Table "public.mpp_2914a_1_prt_buyitnow_2_prt_1"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_buyitnow_2_prt_1_check" CHECK (buydate >= '01-01-2001'::date AND buydate < '01-01-2002'::date)
    "mpp_2914a_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914a_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914a_1_prt_buyitnow_2_prt_2"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_buyitnow_2_prt_2_check" CHECK (buydate >= '01-01-2002'::date AND buydate < '01-01-2003'::date)
    "mpp_2914a_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914a_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914a_1_prt_buyitnow_2_prt_3"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_buyitnow_2_prt_3_check" CHECK (buydate >= '01-01-2003'::date AND buydate < '01-01-2004'::date)
    "mpp_2914a_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914a_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914a_1_prt_buyitnow_2_prt_4"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_buyitnow_2_prt_4_check" CHECK (buydate >= '01-01-2004'::date AND buydate < '01-01-2005'::date)
    "mpp_2914a_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914a_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914a_1_prt_buyitnow_2_prt_5"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_buyitnow_2_prt_5_check" CHECK (buydate >= '01-01-2005'::date)
    "mpp_2914a_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914a_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914a_1_prt_catchall"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Inherits: mpp_2914a
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (buydate)

Table "public.mpp_2914a_1_prt_catchall_2_prt_1"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_catchall_2_prt_1_check" CHECK (buydate >= '01-01-2001'::date AND buydate < '01-01-2002'::date)
Inherits: mpp_2914a_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914a_1_prt_catchall_2_prt_2"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_catchall_2_prt_2_check" CHECK (buydate >= '01-01-2002'::date AND buydate < '01-01-2003'::date)
Inherits: mpp_2914a_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914a_1_prt_catchall_2_prt_3"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_catchall_2_prt_3_check" CHECK (buydate >= '01-01-2003'::date AND buydate < '01-01-2004'::date)
Inherits: mpp_2914a_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914a_1_prt_catchall_2_prt_4"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_catchall_2_prt_4_check" CHECK (buydate >= '01-01-2004'::date AND buydate < '01-01-2005'::date)
Inherits: mpp_2914a_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914a_1_prt_catchall_2_prt_5"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914a_1_prt_catchall_2_prt_5_check" CHECK (buydate >= '01-01-2005'::date)
Inherits: mpp_2914a_1_prt_catchall
Distributed by: (id)

create table mpp_2914B(id int,  buyDate date, kind char(1))
DISTRIBUTED BY (id)
partition by list (kind)
subpartition by range(buyDate)
(
        partition auction  values('a','A')
        (
                subpartition  y2001 start (date '2001-01-01'),
                subpartition  y2002 start (date '2002-01-01'),
                subpartition  y2003 start (date '2003-01-01'),
                subpartition y2004 start (date '2004-01-01'),
                subpartition y2005 start (date '2005-01-01')
        ),
        partition buyitnow  values('b','B')
        (
                subpartition  y2001 start (date '2001-01-01'),
                subpartition  y2002 start (date '2002-01-01'),
                subpartition  y2003 start (date '2003-01-01'),
                subpartition y2004 start (date '2004-01-01'),
                subpartition y2005 start (date '2005-01-01')
        ),
        default partition catchAll  
        (
                subpartition  y2001 start (date '2001-01-01'),
                subpartition  y2002 start (date '2002-01-01'),
                subpartition  y2003 start (date '2003-01-01'),
                subpartition y2004 start (date '2004-01-01'),
                subpartition y2005 start (date '2005-01-01')
        )
);
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_auction" for table "mpp_2914b"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_auction_2_prt_y2001" for table "mpp_2914b_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_auction_2_prt_y2002" for table "mpp_2914b_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_auction_2_prt_y2003" for table "mpp_2914b_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_auction_2_prt_y2004" for table "mpp_2914b_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_auction_2_prt_y2005" for table "mpp_2914b_1_prt_auction"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_buyitnow" for table "mpp_2914b"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_buyitnow_2_prt_y2001" for table "mpp_2914b_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_buyitnow_2_prt_y2002" for table "mpp_2914b_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_buyitnow_2_prt_y2003" for table "mpp_2914b_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_buyitnow_2_prt_y2004" for table "mpp_2914b_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_buyitnow_2_prt_y2005" for table "mpp_2914b_1_prt_buyitnow"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_catchall" for table "mpp_2914b"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_catchall_2_prt_y2001" for table "mpp_2914b_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_catchall_2_prt_y2002" for table "mpp_2914b_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_catchall_2_prt_y2003" for table "mpp_2914b_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_catchall_2_prt_y2004" for table "mpp_2914b_1_prt_catchall"
NOTICE:  CREATE TABLE will create partition "mpp_2914b_1_prt_catchall_2_prt_y2005" for table "mpp_2914b_1_prt_catchall"
select count(*) from mpp_2914B;
 count 
-------
     0
(1 row)

\d mpp_2914b*
      Table "public.mpp_2914b"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Number of child tables: 3 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (kind)

Table "public.mpp_2914b_1_prt_auction"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914b
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (buydate)

Table "public.mpp_2914b_1_prt_auction_2_prt_y2001"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_auction_2_prt_y2001_check" CHECK (buydate >= '01-01-2001'::date AND buydate < '01-01-2002'::date)
    "mpp_2914b_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914b_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914b_1_prt_auction_2_prt_y2002"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_auction_2_prt_y2002_check" CHECK (buydate >= '01-01-2002'::date AND buydate < '01-01-2003'::date)
    "mpp_2914b_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914b_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914b_1_prt_auction_2_prt_y2003"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_auction_2_prt_y2003_check" CHECK (buydate >= '01-01-2003'::date AND buydate < '01-01-2004'::date)
    "mpp_2914b_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914b_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914b_1_prt_auction_2_prt_y2004"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_auction_2_prt_y2004_check" CHECK (buydate >= '01-01-2004'::date AND buydate < '01-01-2005'::date)
    "mpp_2914b_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914b_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914b_1_prt_auction_2_prt_y2005"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_auction_2_prt_y2005_check" CHECK (buydate >= '01-01-2005'::date)
    "mpp_2914b_1_prt_auction_check" CHECK (kind = 'a'::bpchar OR kind = 'A'::bpchar)
Inherits: mpp_2914b_1_prt_auction
Distributed by: (id)

Table "public.mpp_2914b_1_prt_buyitnow"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914b
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (buydate)

Table "public.mpp_2914b_1_prt_buyitnow_2_prt_y2001"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_buyitnow_2_prt_y2001_check" CHECK (buydate >= '01-01-2001'::date AND buydate < '01-01-2002'::date)
    "mpp_2914b_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914b_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914b_1_prt_buyitnow_2_prt_y2002"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_buyitnow_2_prt_y2002_check" CHECK (buydate >= '01-01-2002'::date AND buydate < '01-01-2003'::date)
    "mpp_2914b_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914b_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914b_1_prt_buyitnow_2_prt_y2003"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_buyitnow_2_prt_y2003_check" CHECK (buydate >= '01-01-2003'::date AND buydate < '01-01-2004'::date)
    "mpp_2914b_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914b_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914b_1_prt_buyitnow_2_prt_y2004"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_buyitnow_2_prt_y2004_check" CHECK (buydate >= '01-01-2004'::date AND buydate < '01-01-2005'::date)
    "mpp_2914b_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914b_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914b_1_prt_buyitnow_2_prt_y2005"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_buyitnow_2_prt_y2005_check" CHECK (buydate >= '01-01-2005'::date)
    "mpp_2914b_1_prt_buyitnow_check" CHECK (kind = 'b'::bpchar OR kind = 'B'::bpchar)
Inherits: mpp_2914b_1_prt_buyitnow
Distributed by: (id)

Table "public.mpp_2914b_1_prt_catchall"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Inherits: mpp_2914b
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (id)
Partition by: (buydate)

Table "public.mpp_2914b_1_prt_catchall_2_prt_y2001"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_catchall_2_prt_y2001_check" CHECK (buydate >= '01-01-2001'::date AND buydate < '01-01-2002'::date)
Inherits: mpp_2914b_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914b_1_prt_catchall_2_prt_y2002"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_catchall_2_prt_y2002_check" CHECK (buydate >= '01-01-2002'::date AND buydate < '01-01-2003'::date)
Inherits: mpp_2914b_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914b_1_prt_catchall_2_prt_y2003"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_catchall_2_prt_y2003_check" CHECK (buydate >= '01-01-2003'::date AND buydate < '01-01-2004'::date)
Inherits: mpp_2914b_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914b_1_prt_catchall_2_prt_y2004"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_catchall_2_prt_y2004_check" CHECK (buydate >= '01-01-2004'::date AND buydate < '01-01-2005'::date)
Inherits: mpp_2914b_1_prt_catchall
Distributed by: (id)

Table "public.mpp_2914b_1_prt_catchall_2_prt_y2005"
 Column  |     Type     | Modifiers 
---------+--------------+-----------
 id      | integer      | 
 buydate | date         | 
 kind    | character(1) | 
Check constraints:
    "mpp_2914b_1_prt_catchall_2_prt_y2005_check" CHECK (buydate >= '01-01-2005'::date)
Inherits: mpp_2914b_1_prt_catchall
Distributed by: (id)

drop table mpp_2914a cascade;
drop table mpp_2914b cascade;