You can wrap syntax that jOOQ's parser doesn't understand with a special
comment syntax explained here:
https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-parser/

On Fri, Aug 22, 2025 at 11:55 AM tuk <subharaj.ma...@gmail.com> wrote:

> Thanks for replying.
>
> I am using Jooq 3.19.25 Open source edition. I tried something like below
>
> class TableExtractorTest {
>
>     @Test
>     @SneakyThrows
>     void test() {
>         String sql = new
> String(Files.readAllBytes(Paths.get("/tmp/create_db.sql")));
>
>         Parser parser = DSL.using(SQLDialect.MYSQL).parser();
>         Queries queries = parser.parse(sql);
>
>         Set<String> tableNames = new HashSet<>();
>
>         for (Query query : queries) {
>             Configuration configuration = DSL.using(SQLDialect.MYSQL)
>                     .configuration()
>                     .derive(() -> new DefaultVisitListener() {
>                         @Override
>                         public void visitStart(VisitContext context) {
>                             if (context.queryPart() instanceof Table) {
>                                 Table<?> table = (Table<?>)
> context.queryPart();
>                                 tableNames.add(table.getName());
>                             }
>                         }
>                     });
>             DSL.using(configuration).render(query);
>         }
>
>         System.out.println("Tables found: " + tableNames);
>     }
> }
>
> But it is failing for queries like below
>
> CREATE TABLE IF NOT EXISTS `audit_control`
> (
>    `id`            BIGINT auto_increment NOT NULL,
>    `message_id`    VARCHAR(100) DEFAULT NULL,
>     `resource_type` VARCHAR(30) NOT NULL,
>     `event_type`    VARCHAR(30) NOT NULL,
>     `resource_id`   INT NOT NULL,
>     `origin`        VARCHAR(100) NOT NULL,
>     `created_at`    TIMESTAMP NOT NULL,
>     `body`          mediumtext NOT NULL,
>     `audit_ts`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
>     PRIMARY KEY (id, audit_ts),
>     KEY `audit_control_resource_type_resource_id_IDX`
> (`resource_type`,`resource_id`) USING BTREE,
>     KEY `audit_control_created_at_IDX` (`created_at`) USING BTREE
>     ) PARTITION BY RANGE ( UNIX_TIMESTAMP(audit_ts)) (
>     PARTITION p2401 VALUES LESS THAN (UNIX_TIMESTAMP('2024-02-01
> 00:00:00')),
>     PARTITION p2402 VALUES LESS THAN (UNIX_TIMESTAMP('2024-03-01
> 00:00:00')),
>     PARTITION p2403 VALUES LESS THAN (UNIX_TIMESTAMP('2024-04-01
> 00:00:00')),
>     PARTITION p2404 VALUES LESS THAN (UNIX_TIMESTAMP('2024-05-01
> 00:00:00')),
>     PARTITION p2405 VALUES LESS THAN (UNIX_TIMESTAMP('2024-06-01
> 00:00:00')),
>     PARTITION p2406 VALUES LESS THAN (UNIX_TIMESTAMP('2024-07-01
> 00:00:00')),
>     PARTITION p2407 VALUES LESS THAN (UNIX_TIMESTAMP('2024-08-01
> 00:00:00')),
>     PARTITION p2408 VALUES LESS THAN (UNIX_TIMESTAMP('2024-09-01
> 00:00:00')),
>     PARTITION p2409 VALUES LESS THAN (UNIX_TIMESTAMP('2024-10-01
> 00:00:00')),
>     PARTITION p2410 VALUES LESS THAN (UNIX_TIMESTAMP('2024-11-01
> 00:00:00')),
>     PARTITION p2411 VALUES LESS THAN (UNIX_TIMESTAMP('2024-12-01
> 00:00:00')),
>     PARTITION p2412 VALUES LESS THAN (UNIX_TIMESTAMP('2025-01-01
> 00:00:00')),
>     PARTITION pN VALUES LESS THAN MAXVALUE
> );
>
> I am getting the below error
>
> org.jooq.impl.ParserException: Unsupported query type: [18:7]
> ..._created_at_IDX` (`created_at`) USING BTREE
>     ) [*]PARTITION BY RANGE ( UNIX_TIMESTAMP(audit_ts)) (
>                                ...
>
> at
> org.jooq.impl.AbstractParseContext.exception(AbstractParseContext.java:173)
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jooq-user+unsubscr...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/jooq-user/6fcb4db9-e167-4cf7-a99e-e5c412eaa4b4n%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/6fcb4db9-e167-4cf7-a99e-e5c412eaa4b4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5xJcgE92nUBb1xHkVoni33_Bj-i5YHNVAxo4SHiD4muQ%40mail.gmail.com.

Reply via email to