Closed jmafc closed 6 years ago
@dvarrazzo @rhunwicks @darthunix @tbussmann
I have started working on this and would like some feedback. When pg_dump
outputs a partitioned table and its partitions, it looks as in the following example:
CREATE TABLE t1 (
c1 integer NOT NULL,
c2 text
)
PARTITION BY RANGE (c1);
CREATE TABLE t1a PARTITION OF t1
FOR VALUES FROM (0) TO (1000);
I'm proposing to follow a similar pattern, i.e., the partitions will not show the column details. Currently the proposed dbtoyaml
output looks as follows:
table t1:
columns:
- c1:
not_null: true
type: integer
- c2:
type: text
partition_by: range
table t1a:
inherits:
- t1
partition_bound_spec: FROM (0) TO (1000)
The inherits
comes automatically from existing code, but perhaps we could change it to partition_of
(leaving the list spec for t1
although partitions inherit from only a single table).
Still missing are the columns and/or expressions used for partitioning. I'm proposing to add them under partition_by
as keys
(the PG documentation states "The parenthesized list of columns or expressions forms the partition key for the table") followed by a YAML list, e.g.,
partition_by: range
keys:
- c1
Comments?
I've worked on this (and after noticing my YAML error in the last part above), I've decided to implement something that looks as follows:
table t1:
columns:
- c1:
not_null: true
type: integer
- c2:
type: text
partition_by:
range:
- c1
table t1a:
partition_of: t1
partition_bound_spec: FROM (0) TO (1000)
The partition_of
part is already done, so now I have to add the list of columns and expressions.
Closing this issue. Missing support for expressions will be addressed in #178.
Coming in PG 10. See https://www.postgresql.org/docs/devel/static/sql-createtable.html#sql-createtable-partition