### Option 2: Specify SUBPARTITION BY as part of the subpartitiontemplate
#### ALTER TABLE SET PARTITION TEMPLATE
Currently we specify subpartition template like this[2]:```SET SUBPARTITION TEMPLATE (subpartition_spec)```
I propose we update/extend the syntax to:
```SET SUBPARTITION TEMPLATE [ SUBPARTITION BY partition_type (column1)] (subpartition_spec)```
This allows us to also store the PartitionKey info as a new column inthe `gp_partition_template` catalog table. With this informationavailable as part of the template itself, we will no longer need toretrieve the first partition when ALTER TABLE ADD PARTITION on a tablewho has subpartition template.
***Since this is catalog change, if we want it, we should do it now.***
We could perhaps make the SUBPARTITION BY clause optional for backwardcompatibility and still use the first partition's PartitionKey info ifuser didn't specify one AND if we have at least one child partitionpresent, but we will always record the PartitionKey info in the`gp_partition_template` catalog table.
## Problems
In my opinion there are two problems:
1. The inconsistency of allowing or disallowing zero child partitions.2. The dependency on the first partition's partition strategy/key withALTER TABLE ADD PARTITION and ALTER TABLE SET PARTITION TEMPLATE
On Mon, Oct 17, 2022 at 5:27 PM 'Alexandra Wang' via Greenplum Developers <gpdb...@greenplum.org> wrote:### Option 2: Specify SUBPARTITION BY as part of the subpartitiontemplate
#### ALTER TABLE SET PARTITION TEMPLATE
Currently we specify subpartition template like this[2]:```SET SUBPARTITION TEMPLATE (subpartition_spec)```
I propose we update/extend the syntax to:
```SET SUBPARTITION TEMPLATE [ SUBPARTITION BY partition_type (column1)] (subpartition_spec)```Current syntax provides flexibility to have heterogeneous hierarchy under sub-partition though the subpartition remains the same. With newer syntax we are proposing to provide flexibility to even allow users to change subpartition by keys. Do we fully understand the implications of that?
This allows us to also store the PartitionKey info as a new column inthe `gp_partition_template` catalog table. With this informationavailable as part of the template itself, we will no longer need toretrieve the first partition when ALTER TABLE ADD PARTITION on a tablewho has subpartition template.
***Since this is catalog change, if we want it, we should do it now.***
We could perhaps make the SUBPARTITION BY clause optional for backwardcompatibility and still use the first partition's PartitionKey info ifuser didn't specify one AND if we have at least one child partitionpresent, but we will always record the PartitionKey info in the`gp_partition_template` catalog table.Backward compatibility is the key aspect for supporting these legacy GPDB partition syntax, if it needs modification best to force users to use the newer upstream syntax. So, it has to be optional for sure.
What if we store the subpartition by clause (specified as its today) in the catalog without providing any kind of newer syntax to the user? That would just decouple the dependency on child partition and template would be self contained without any user side syntax change? Just in case in future need arises to modify the subpartition by as well then we visit adding newer syntax.
IMO the inconsistency is not a big deal even there might be other inconsistencies in production.
It’s fine for backward compatibility and changing behaviors breaks the compatibility. I take it as “we
only provide new feature or behavior changes with the new syntax”.
From:
Ashwin Agrawal <ashwi...@gmail.com>
Date: Wednesday, October 19, 2022 at 02:02
To: Alexandra Wang <walex...@vmware.com>
Cc: Greenplum Developers <gpdb...@greenplum.org>
Subject: Re: GPDB7 Partitioning commands: remove guard for "one partition must remain"
⚠ External Email
⚠ External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.
> IMO the inconsistency is not a big deal even there might be other inconsistencies in production.
> It’s fine for backward compatibility and changing behaviors breaks the compatibility. I take it as “we
> only provide new feature or behavior changes with the new syntax”.
Existing syntax[3]:
SET SUBPARTITION TEMPLATE (subpartition_spec)
Proposed syntax:
SET SUBPARTITION TEMPLATE [ SUBPARTITION BY partition_type (column1)] (subpartition_spec)
For 2, I'd like to hear opinions about whether or not to make theSUBPARTITION BY clause optional. If we make it optional, we'd have thesyntax "backward compatible", but we'd still have to retrive the firstchild partition to infer the subpartition key, which I think isundesirable. Given that SUBPARTITION TEMPLATE is usually set as partof the CREATE TABLE statement, I wonder how often a user would use theALTER TABLE SET SUBPARTITION TEMPLATE command to add or modifysubpartition template. Would it be better to just make theSUBPARTITION BY clause mandatory?
⚠ External Email