Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser: Implement table partitions #59

Open
KieranKaelin opened this issue Mar 1, 2023 · 0 comments
Open

Parser: Implement table partitions #59

KieranKaelin opened this issue Mar 1, 2023 · 0 comments
Labels
enhancement New feature or request parser Parser functionality

Comments

@KieranKaelin
Copy link
Contributor

KieranKaelin commented Mar 1, 2023

Dependent on #58.


The first iteration on tables, #58, did not cover partitions.

Goal

The parser shall fully understand partitions and subpartitions.

For reference, see the Oracle documentation table_partitioning_clauses.

Examples

-- List partition
CREATE TABLE "HR"."LIST_PARTITION" ("STATE_CODE" VARCHAR2(6 BYTE))
PARTITION BY LIST ("STATE_CODE") (
  PARTITION "REGION_EAST"  VALUES ('MA', 'NY', 'CT', 'NH', 'ME', 'MD', 'VA', 'PA', 'NJ') SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 8388608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ,
  PARTITION "REGION_NULL"  VALUES (NULL),
  PARTITION "REGION_UNKNOWN"  VALUES (DEFAULT)
-- Hash partition
CREATE TABLE "HR"."HASH_PARTITION"("ID" NUMBER(4,0))
PARTITION BY HASH ("ID") (
  PARTITION "SYS_P1933" SEGMENT CREATION IMMEDIATE TABLESPACE "USERS" NOCOMPRESS,
  PARTITION "SYS_P1934" SEGMENT CREATION DEFERRED,
  PARTITION "SYS_P1935" SEGMENT CREATION IMMEDIATE,
  PARTITION "SYS_P1936" SEGMENT CREATION IMMEDIATE
-- Hash partition by quantity
CREATE TABLE "HR"."HASH_PARTITIONS_BY_QUANTITY"("ID" NUMBER) PARTITION BY HASH ("ID") PARTITIONS 2;
-- Range partition
CREATE TABLE "HR"."RANGE_PARTITION"("SUPPLIER_ID" NUMBER,"PART_ID" NUMBER)
PARTITION BY RANGE ("SUPPLIER_ID","PART_ID") (
    PARTITION "P1"  VALUES LESS THAN (10, 100) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 8388608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS",
    PARTITION "P2"  VALUES LESS THAN (10, 200),
    PARTITION "P3"  VALUES LESS THAN (MAXVALUE, MAXVALUE)
);
-- Hash partition with list subpartition
CREATE TABLE "HR"."HASH_WITH_LIST_SUBPARTITION"("ID" NUMBER(4,0), "NUM" NUMBER)
            PARTITION BY HASH ("ID")
            SUBPARTITION BY LIST ("NUM")
            SUBPARTITION TEMPLATE (
                SUBPARTITION "PLAYER_1" VALUES ( 1 ),
                SUBPARTITION "OTHERS" VALUES ( DEFAULT )
            ) (
                PARTITION "SYS_P1943" TABLESPACE "USERS",
                PARTITION "SYS_P1944"
        );

How to demo

Appropriate tests are created showcasing the resulting AST and AST accessors to iterate and inspect the table properties.

@KieranKaelin KieranKaelin added enhancement New feature or request parser Parser functionality labels Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser Parser functionality
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant