Wire DuckDB 2.0 support into sqlc parse and sqlc analyze through
darkwing, the pure Go port of DuckDB's PEG parser:
- internal/engine/duckdb: parser wrapper and converter from darkwing's
AST to sqlc's. darkwing's statement spans tile the input, so each
statement carries its leading comments for query annotations, and
darkwing numbers every parameter spelling ($1, ?, $name) itself.
- internal/engine/duckdb/dialect: the type system seed for the analysis
core. types.jsonl, functions.jsonl and operators.jsonl are generated
from a live DuckDB 2.0 CLI by the new sqlc-duckdb-gen tool
(internal/tools/sqlc-duckdb-gen), which maps DuckDB's polymorphic
function parameters onto the analyzer's "any" resolution.
- config, compiler and the parse/analyze commands register the engine;
parse errors carry DuckDB's native messages with byte-accurate
positions.
- end-to-end cases under parse_basic, analyze_basic, analyze_params,
analyze_dml and analyze_select cover the dialect.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016uPxbu16EDkadTKbWwHUiE
Adds DuckDB 2.0 support to sqlc parse and sqlc analyze through darkwing v0.1.0, the pure Go port of DuckDB 2.0's PEG parser.
Engine (internal/engine/duckdb)
Generated dialect seeds (internal/tools/sqlc-duckdb-gen)
Like sqlc-pg-gen, the dialect files are generated from a live database rather than written by hand: the new tool runs the pinned DuckDB CLI (v2.0.0-alpha38195 (Cyanoptera) 8cbdaba6ac, the same nightly darkwing's grammar is pinned to) and dumps duckdb_types() / duckdb_functions() into:
Only dialect.json is authored by hand. Regenerate with DUCKDB=/path/to/duckdb go run ./internal/tools/sqlc-duckdb-gen.
Wiring
config.EngineDuckDB; the compiler routes DuckDB through the core analyzer unconditionally (like ClickHouse/GoogleSQL/MSSQL there is no legacy path, and no database is needed); --dialect duckdb in both commands; docs updated.
Tests
Five end-to-end cases with committed goldens, all passing under TestReplay/base:
Known v1 limits, consistent with the other core-only engines: PIVOT/DESCRIBE/COLUMNS(...) and star EXCLUDE/REPLACE convert to TODO nodes, and sqlc macro syntax (sqlc.arg() etc.) is not yet preprocessed for DuckDB.
🤖 Generated with Claude Code
https://claude.ai/code/session_016uPxbu16EDkadTKbWwHUiE
Generated by Claude Code