Commit 6074ae9
Add duckdb_quote_identifier() to fix identifier quoting for DuckDB pushdown
DuckDB reserves several keywords that PostgreSQL does not (LAMBDA, PIVOT,
PIVOT_LONGER, PIVOT_WIDER, QUALIFY, SUMMARIZE, DESCRIBE, SHOW, UNPIVOT).
Using PostgreSQL's quote_identifier() on column names sent to pgduck_server
silently omits the extra quoting those reserved words require, causing query
failures at runtime.
This commit:
- Adds tools/generate_duckdb_kwlist.py, a script that parses the vendored
DuckDB kwlist.hpp and emits pg_lake_engine/src/pgduck/duckdb_kwlist.h — a
sorted C include fragment used to initialise the keyword lookup table.
The generated file is checked in; re-run `make generate-duckdb-kwlist`
after a DuckDB version bump.
- Adds `make generate-duckdb-kwlist` and `make check-duckdb-kwlist` targets.
The check target verifies the generated file is up to date and can be wired
into CI.
- Rewrites keywords.c to use the DuckDB-accurate keyword table instead of
PostgreSQL's parser/kwlist.h. Adds duckdb_quote_identifier(), which falls
through to quote_identifier() for normal identifiers and additionally quotes
identifiers that are RESERVED_KEYWORD in DuckDB.
- Exports duckdb_quote_identifier() from keywords.h.
- Replaces quote_identifier() with duckdb_quote_identifier() in all files
that generate SQL sent to pgduck_server:
- pg_lake_engine/src/pgduck/read_data.c (23 call sites)
- pg_lake_engine/src/pgduck/write_data.c (5 call sites)
- pg_lake_engine/src/pgduck/iceberg_query_validation.c (4 call sites)
- pg_lake_table/src/fdw/deparse.c (7 call sites, plus audit TODO note)
PostgreSQL-only callers (pg_extension_updater, base_worker_launcher,
data_files_catalog, EXPLAIN output in pg_lake_table.c) are left unchanged.
Fixes #277.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: David Christensen <david.christensen@snowflake.com>1 parent 5638b9f commit 6074ae9
File tree
9 files changed
+832
-66
lines changed- pg_lake_engine
- include/pg_lake/pgduck
- src/pgduck
- pg_lake_table/src/fdw
- tools
9 files changed
+832
-66
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
223 | 234 | | |
224 | 235 | | |
225 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments