Introduce `parser_override_function_t` by Dtenwolde · Pull Request #19126 · duckdb/duckdb · GitHub
Skip to content

Introduce parser_override_function_t - #19126

Merged
Mytherin merged 5 commits into
duckdb:mainfrom
Dtenwolde:parser_override_function_t
Sep 26, 2025
Merged

Mytherin merged 5 commits into
duckdb:mainfrom
Dtenwolde:parser_override_function_t

Conversation

@Dtenwolde

Copy link
Copy Markdown
Member

This is a follow-up/improvement over #18937

It adds a new function pointer parser_override_function_t as part of the ParserExtension with which extensions can override the current parser. This hook is executed before the current parser and takes as input the entire query string, which can contain multiple statements and returns a vector of (potentially multiple) statement(s). The ParserOverride can also return either (1) a custom error message which is turned into a ParserException (2) Failed parse in which case DuckDB's parser can try to parse & transform the query.

In a follow-up PR I will add the PEG parser which will make use of this new hook.

@Dtenwolde
Dtenwolde marked this pull request as draft September 24, 2025 12:10
@Dtenwolde
Dtenwolde marked this pull request as ready for review September 24, 2025 12:10
@Dtenwolde

Copy link
Copy Markdown
Member Author

@duckdb-draftbot
duckdb-draftbot marked this pull request as draft September 25, 2025 14:09
@Dtenwolde
Dtenwolde marked this pull request as ready for review September 25, 2025 15:09
@Mytherin
Mytherin merged commit 4bfb6e2 into duckdb:main Sep 26, 2025
54 checks passed
@Mytherin

Copy link
Copy Markdown
Member

Mytherin added a commit that referenced this pull request Oct 13, 2025
Follow-up PR to #19181 (I rebased
this branch onto the one in the PR so it should include everything)

This PR introduces (once again) the `ParseResult` concrete syntax tree
structure used by the PEG Transformer.
These `ParseResult`s make use of a `ParseResultAllocator` similar to the
`MatcherAllocator`.

The PR also fixes a (potential) bug related to improperly initializing
the `ParserExtension`. I now initialize all those pointers to `nullptr`
otherwise they can contain garbage value I found.

I reworked the way the PEG Parser is called, it now uses the
`ParserExtension` and `parser_override_function_t` introduced in:
#19126

It includes the structure of the `PEGTransformer` but does not actually
transform any form of statement yet. My plan is to introduce some of the
simpler statements, such as `SET`, `RESET`, `PRAGMA` in a follow-up PR.

Regarding testing this new transformer I was considering adding a new
mode to `ALTERNATIVE_VERIFY` that reruns the query using the
`PEGTransformer` and checks for inconsistent results. An issue I see is
that the list of incorrect results will be huge until a large part of
the transformer is implemented. Should all those tests simply be
excluded or can we run subsets of tests and exclude other tests?
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Oct 21, 2025
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Nov 1, 2025
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Nov 2, 2025
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants