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 ms
quote_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
SELECT or INSERT...SELECT (deparse layer in deparse.c)
- Composite field names in the temporal validation
struct_pack generation (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
I realized while reviewing #274, but seems a lot more common than that.
quote_identifier()uses PostgreSQL's keyword list to decide whether to double-quote identifiers in SQL sent to DuckDB (pgduck_server). Identifiers that are DuckDBRESERVED_KEYWORDbut not PostgreSQL keywords pass through unquoted, causing DuckDB parse errors.This affects:
SELECTorINSERT...SELECT(deparse layer indeparse.c)struct_packgeneration (iceberg_query_validation.c)Affected keywords
DuckDB
RESERVED_KEYWORDtokens that are not PostgreSQL keywords (and thus never quoted byquote_identifier()):describelambdapivotpivot_longerpivot_widerqualifysummarizeunpivotshowSource:
duckdb_pglake/duckdb/third_party/libpg_query/include/parser/kwlist.hpp