Commit 3eb6e0f
authored
Support DuckDB main (PEG parser): port expression FFI + parser-swap regression test (#38)
* Add parser-agnostic regression test for DuckDB parser swap
DuckDB is replacing its legacy PostgreSQL parser with a PEG parser (opt-in
in 1.5, the sole parser on main, default in 2.0). Yardstick integrates via
allow_parser_override_extension="fallback", so when the override declines a
query, DuckDB's parser handles it -- including surfacing syntax errors, whose
shape differs between the legacy and PEG parsers.
Add test/sql/peg_parser.test guarding the two behaviors most exposed to the
swap: the parser_override rewrite path still works, and the fallback path
still raises a parser-agnostic "Parser Error". The test runs under whichever
parser the build uses, so it becomes PEG coverage automatically once the suite
runs against a PEG-default DuckDB.
* Port parser FFI to DuckDB main's expression API (dual-API)
DuckDB main refactored the parsed-expression API: subclass fields are now
private (accessed via FunctionName()/GetArgumentsMutable()/LeftMutable()/...)
and names use a dedicated Identifier type instead of std::string. This broke
the duckdb-next-build CI lane (compile failure in yardstick_parser_ffi.cpp),
which has been red for a week.
Add a small compatibility shim, selected at compile time via
__has_include("duckdb/common/identifier.hpp") (matching the project's existing
__has_include pattern), and route all expression field access through it. The
old field-based API (DuckDB 1.5 and the pinned submodule) and the new
accessor-based API (main) are both supported, so the stable and next CI lanes
both build.
Behavior is unchanged: the shim is a pure access adaptation over the same tree
walks. Verified with -fsyntax-only against both DuckDB main and v1.5-variegata
headers (0 errors each).
* Port ParserExtension parse_function to DuckDB main's token API
Fixing the expression FFI let the next-build compile advance to the next
DuckDB-main API change: parse_function_t now receives the post-PEG-failure
token tail (const vector<SimpleToken>&) instead of the raw query string
(yardstick_extension.hpp/.cpp).
Yardstick does all of its rewriting in yardstick_parser_override, which still
receives the full query string on both APIs, so on the new signature
parse_function is a no-op fallback. The old string-based fallback is retained
for DuckDB 1.5 via the same __has_include detection. Matching yardstick_parse
to parse_function_t also fixes the function-pointer comparison in yardstick_bind.
Verified with -fsyntax-only against both DuckDB main and v1.5-variegata (0
errors); all three extension translation units now compile against main.1 parent 9d676ca commit 3eb6e0f
4 files changed
Lines changed: 423 additions & 115 deletions
File tree
- src
- include
- test/sql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
25 | 41 | | |
26 | 42 | | |
| 43 | + | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
333 | 343 | | |
334 | 344 | | |
335 | 345 | | |
| |||
422 | 432 | | |
423 | 433 | | |
424 | 434 | | |
| 435 | + | |
425 | 436 | | |
426 | 437 | | |
427 | 438 | | |
| |||
0 commit comments