Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions contrib/pax_storage/expected/cluster.out
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,32 @@ select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_lexical_
(6 rows)

drop table t_lexical_cluster;
-- Reject unsupported options before changing any PAX micro-partitions.
create table t_cluster_options(c1 int, c2 int) using pax
with (minmax_columns='c1,c2', cluster_columns='c1,c2')
distributed by (c1);
insert into t_cluster_options select i, 1001-i from generate_series(1,1000) i;
select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options');
clustered
-----------
f
(1 row)

cluster (bogus) t_cluster_options;
ERROR: unrecognized CLUSTER option "bogus"
LINE 1: cluster (bogus) t_cluster_options;
^
select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options');
clustered
-----------
f
(1 row)

cluster (verbose false) t_cluster_options;
select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options');
clustered
-----------
t
(1 row)

drop table t_cluster_options;
13 changes: 12 additions & 1 deletion contrib/pax_storage/sql/cluster.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,15 @@ alter table t_lexical_cluster set(cluster_columns='c1,c2', cluster_type='lexical
cluster t_lexical_cluster;
select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_lexical_cluster');

drop table t_lexical_cluster;
drop table t_lexical_cluster;
-- Reject unsupported options before changing any PAX micro-partitions.
create table t_cluster_options(c1 int, c2 int) using pax
with (minmax_columns='c1,c2', cluster_columns='c1,c2')
distributed by (c1);
insert into t_cluster_options select i, 1001-i from generate_series(1,1000) i;
select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options');
cluster (bogus) t_cluster_options;
select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options');
cluster (verbose false) t_cluster_options;
select bool_and(ptisclustered) as clustered from get_pax_aux_table('t_cluster_options');
drop table t_cluster_options;
21 changes: 21 additions & 0 deletions contrib/pax_storage/src/cpp/access/pax_access_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,27 @@ static void paxProcessUtility(PlannedStmt *pstmt, const char *queryString,
switch (nodeTag(pstmt->utilityStmt)) {
case T_ClusterStmt: {
ClusterStmt *stmt = (ClusterStmt *)pstmt->utilityStmt;
ListCell *lc;

/*
* Column-based clustering bypasses cluster(), so validate options
* before either the single-table or database-wide PAX path runs.
*/
foreach (lc, stmt->params) {
DefElem *opt = (DefElem *)lfirst(lc);

if (strcmp(opt->defname, "verbose") == 0) {
(void)defGetBoolean(opt);
} else {
ParseState *pstate = make_parsestate(NULL);
pstate->p_sourcetext = queryString;
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unrecognized CLUSTER option \"%s\"", opt->defname),
parser_errposition(pstate, opt->location)));
}
}

if (stmt->relation) {
Relation rel = table_openrv(stmt->relation, AccessShareLock);
if (RelationIsPAX(rel)) {
Expand Down
Loading