-
Notifications
You must be signed in to change notification settings - Fork 86
DuckDB reserved keywords used as column/field names cause parse errors in pushed-down queries #277
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I realized while reviewing #274, but seems a lot more common than that.
CREATE TABLE t_pivot_bug (pivot int, b text) USING iceberg;
CREATE TABLE
Time: 21.265 ms
postgres=# INSERT INTO t_pivot_bug VALUES (1, 'hello');
ERROR: Parser Error: syntax error at or near "pivot"
LINE 1: COPY (SELECT pivot, b FROM read_csv('/Users/okalaci/pg-install/data_pg17...
^
LINE 1: COPY (SELECT pivot, b FROM read_csv('/Users/okalaci/pg-install/data_pg17...
^
Time: 8.201 msquote_identifier() uses PostgreSQL's keyword list to decide whether to double-quote identifiers in SQL sent to DuckDB (pgduck_server). Identifiers that are DuckDB RESERVED_KEYWORD but not PostgreSQL keywords pass through unquoted, causing DuckDB parse errors.
This affects:
- Column names in any pushed-down
SELECTorINSERT...SELECT(deparse layer indeparse.c) - Composite field names in the temporal validation
struct_packgeneration (iceberg_query_validation.c)
Affected keywords
DuckDB RESERVED_KEYWORD tokens that are not PostgreSQL keywords (and thus never quoted by quote_identifier()):
| Keyword | DuckDB category | PostgreSQL status |
|---|---|---|
describe |
RESERVED | not a keyword |
lambda |
RESERVED | not a keyword |
pivot |
RESERVED | not a keyword |
pivot_longer |
RESERVED | not a keyword |
pivot_wider |
RESERVED | not a keyword |
qualify |
RESERVED | not a keyword |
summarize |
RESERVED | not a keyword |
unpivot |
RESERVED | not a keyword |
show |
RESERVED | unreserved (not quoted) |
Source: duckdb_pglake/duckdb/third_party/libpg_query/include/parser/kwlist.hpp
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working