Skip to content

feat: support PostgreSQL COPY WITH options - #2658

Open
minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-copy-with-options
Open

minleejae wants to merge 1 commit into
JSQLParser:masterfrom
minleejae:feat/postgresql-copy-with-options

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

COPY already models table/query sources and STDIN/STDOUT, but rejects PostgreSQL's WITH (FORMAT csv, HEADER true) option syntax. Preserve the optional WITH keyword, including PostgreSQL's accepted WITH-only legacy form, and reject empty option entries in the new WITH form and PostgreSQL dialect.

Reuse CopyStatement's option representation and add a select-writer overload so query expressions reach the configured deparser. Tests cover CSV delimiters/nulls, column-list and wildcard FORCE_QUOTE, HEADER MATCH, ON_ERROR, CTE/UNION queries, AST edits, and malformed lists. Existing DuckDB tests pass. PROGRAM, WHERE, COPY data-body parsing, and DML RETURNING query sources are outside this change.

Syntax reference: PostgreSQL COPY.

Validation:

  • Java 17 Gradle check: 7,829 XML-reported tests, 0 failures/errors, 25 skipped; formatting, grammar ambiguity, Checkstyle, PMD, and JMH compilation passed. Formatting was checked against upstream/master using a local Spotless ratchet override.
  • Actual PostgreSQL 17.11 server: 13 accepted and 6 rejected SQL cases matched the expected behavior.
  • Executed both AST and StatementDeParser output for the accepted cases on the same server: 26 successful executions. COPY FROM STDIN cases also loaded CSV/text rows and verified row counts.

Signed-off-by: minleejae <mmj9808@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant