postgresqljooq

JOOQ "Partition By" Parsing Functionality


When parsing Postgres CREATE DDL Command using JOOQ.

Is there a way of parsing “Partition By” key word. Currently, it will throw exception if there is Partition By keyword.

I am wondering if it is a feature that is going to come out soon or there is any workaround on this that I missed.

I am using JOOQ 3.16.10.

An example of the Postgres SQL Schema would be something like:

CREATE TABLE people (
      id UUID NOT NULL,
      firstName VARCHAR(255) NOT NULL DEFAULT 'John',
      lastName VARCHAR(255),
      age integer[] NOT NULL,
      CONSTRAINT uk UNIQUE (id, firstName),
      CONSTRAINT pk PRIMARY KEY (id)
) Partition By RANGE (age);

Solution

  • As of jOOQ 3.19, this isn't supported yet, see:

    You can comment out the PARTITION BY clause either completely, or using jOOQ's special parser "ignore-comment syntax", if the clause doesn't really matter to your specific jOOQ parser use-case:

    CREATE TABLE people (
          id UUID NOT NULL,
          firstName VARCHAR(255) NOT NULL DEFAULT 'John',
          lastName VARCHAR(255),
          age integer[] NOT NULL,
          CONSTRAINT uk UNIQUE (id, firstName),
          CONSTRAINT pk PRIMARY KEY (id)
    ) 
    /* [jooq ignore start] */
    PARTITION BY RANGE (age)
    /* [jooq ignore stop] */
    ;
    

    This way, the clause continues to work in PostgreSQL, but jOOQ's parser will not see it