Skip to content

Commit 6a01e10

Browse files
committed
Improve reloptions validation for partitioned tables using non-default AMs
Previously, when creating a partitioned table without an explicit `USING` clause, the reloptions (such as minmax_columns) were validated with the assumption that the default_table_access_method is either 'heap', 'ao_row', or 'ao_column'. This could incorrectly reject valid reloptions intended for other table access methods like 'pax'. This patch adjusts the validation logic in DefineRelation() so that reloptions are only validated for partitioned tables if the default AM is one of the known AMs that support reloptions validation. For non-default AMs, reloptions are passed unvalidated to allow extensions to handle them properly. This change enables successful creation of partitioned tables using `USING pax WITH (minmax_columns=...)` without validation errors, even when `default_table_access_method` is set to 'pax'.
1 parent e601fb6 commit 6a01e10

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

contrib/pax_storage/expected/ddl.out

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,26 @@ select 1 from (select count(*) from gp_toolkit.gp_size_of_schema_disk) empty_out
8989
(1 row)
9090

9191
drop table pt_pax;
92+
-- expect create ok
93+
create table pax_test.partition_cow(c1 int, c2 bigint, c3 varchar, c4 text, c5 date, c6 float4, c7 float8, c8 numeric, c9 interval)
94+
partition by range(c1) (start(1) end(15000) every(5000))
95+
with (minmax_columns='c1,c2,c3,c4,c5,c6,c7,c8,c9');
96+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Apache Cloudberry data distribution key for this table.
97+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
98+
-- expect create ok
99+
create table pax_test.partition_cow_1(c1 int, c2 bigint, c3 varchar, c4 text, c5 date, c6 float4, c7 float8, c8 numeric, c9 interval)
100+
partition by range(c1) (start(1) end(15000) every(5000))
101+
using pax with (minmax_columns='c1,c2,c3,c4,c5,c6,c7,c8,c9');
102+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Apache Cloudberry data distribution key for this table.
103+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
104+
set default_table_access_method = heap;
105+
-- expect create fail
106+
create table pax_test.partition_cow_2(c1 int, c2 bigint, c3 varchar, c4 text, c5 date, c6 float4, c7 float8, c8 numeric, c9 interval)
107+
partition by range(c1) (start(1) end(15000) every(5000))
108+
with (minmax_columns='c1,c2,c3,c4,c5,c6,c7,c8,c9');
109+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'c1' as the Apache Cloudberry data distribution key for this table.
110+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
111+
ERROR: unrecognized parameter "minmax_columns"
112+
reset default_table_access_method;
113+
drop table pax_test.partition_cow;
114+
drop table pax_test.partition_cow_1;

contrib/pax_storage/sql/ddl.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,21 @@ PARTITION BY RANGE (date)
5858
SELECT pg_catalog.pg_relation_size('pt_pax'::regclass);
5959
select 1 from (select count(*) from gp_toolkit.gp_size_of_schema_disk) empty_out;
6060
drop table pt_pax;
61+
62+
-- expect create ok
63+
create table pax_test.partition_cow(c1 int, c2 bigint, c3 varchar, c4 text, c5 date, c6 float4, c7 float8, c8 numeric, c9 interval)
64+
partition by range(c1) (start(1) end(15000) every(5000))
65+
with (minmax_columns='c1,c2,c3,c4,c5,c6,c7,c8,c9');
66+
-- expect create ok
67+
create table pax_test.partition_cow_1(c1 int, c2 bigint, c3 varchar, c4 text, c5 date, c6 float4, c7 float8, c8 numeric, c9 interval)
68+
partition by range(c1) (start(1) end(15000) every(5000))
69+
using pax with (minmax_columns='c1,c2,c3,c4,c5,c6,c7,c8,c9');
70+
71+
set default_table_access_method = heap;
72+
-- expect create fail
73+
create table pax_test.partition_cow_2(c1 int, c2 bigint, c3 varchar, c4 text, c5 date, c6 float4, c7 float8, c8 numeric, c9 interval)
74+
partition by range(c1) (start(1) end(15000) every(5000))
75+
with (minmax_columns='c1,c2,c3,c4,c5,c6,c7,c8,c9');
76+
reset default_table_access_method;
77+
drop table pax_test.partition_cow;
78+
drop table pax_test.partition_cow_1;

src/backend/commands/tablecmds.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,12 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
970970
if (OidIsValid(accessMethodId))
971971
(void) table_reloptions_am(accessMethodId, reloptions, 'r', true);
972972
else
973-
(void) partitioned_table_reloptions(reloptions, true);
973+
{
974+
bool validate = !strcasecmp(default_table_access_method, DEFAULT_TABLE_ACCESS_METHOD) ||
975+
!strcasecmp(default_table_access_method, "AO_ROW") ||
976+
!strcasecmp(default_table_access_method, "AO_COLUMN");
977+
(void) partitioned_table_reloptions(reloptions, validate);
978+
}
974979
break;
975980
case RELKIND_RELATION:
976981
case RELKIND_MATVIEW:

0 commit comments

Comments
 (0)