sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

Make `COPY` statement options compliant to Postgres

Open dey4ss opened this issue 1 year ago • 0 comments

While fiddling around with a Postgres instance, I noticed that our syntax for COPY statements is not 100% compliant to Postgres. In detail, we used COPY table_a FROM 'path/to/tbl' WITH FORMAT CSV;, whereas Postgres uses COPY table_a FROM 'path/to/tbl' WITH (FORMAT CSV); – there are brackets around the options. Furthermore, the WITH keyword is optional [1].

The incorrect syntax was introduced in #139 (my bad 😕) and it slipped through the review back then. This PR makes the COPY statement compliant to Postgres again. Furthermore, I used the opportunity to add the encoding as another option. This allows us to apply any specified encoding for imported and exported tables in Hyrise.

[1] https://www.postgresql.org/docs/16/sql-copy.html

dey4ss avatar Aug 08 '24 14:08 dey4ss