[MySQL, Oracle] Parse optimizer hints#2162
Merged
iffyio merged 13 commits intoapache:mainfrom Jan 29, 2026
Merged
Conversation
Contributor
|
@xitep wondering would it not make more sense to support features like these via the new |
Contributor
Author
|
surely it would be one way. (the only premise for that would to be have the next non-comment token after the corresponding keywords covered with a span, like suggested in #2099.) however, when processing such statements, these hints are something you generally don't want to leave out, even when parsing without comments. hence this proposal to embed it directly into the AST. |
76e9c41 to
800a4f3
Compare
iffyio
reviewed
Jan 26, 2026
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
20b7074 to
f80afd0
Compare
iffyio
approved these changes
Jan 29, 2026
ayman-sigma
pushed a commit
to sigmacomputing/sqlparser-rs
that referenced
this pull request
Feb 3, 2026
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
fmguerreiro
pushed a commit
to fmguerreiro/datafusion-sqlparser-rs
that referenced
this pull request
Feb 20, 2026
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
altmannmarcelo
added a commit
to readysettech/datafusion-sqlparser-rs
that referenced
this pull request
Apr 23, 2026
Enable comment-based optimizer hint parsing for the PostgreSQL dialect by overriding `supports_comment_optimizer_hint` to return `true`. PostgreSQL itself does not ship a built-in hint system, but the widely used `pg_hint_plan` extension (https://github.com/ossc-db/pg_hint_plan) introduces hints using the exact same `/*+ ... */` block-comment and `--+ ...` single-line-comment syntax already supported for MySQL and Oracle (apache#2162). Without this flag, parsing a `pg_hint_plan` statement such as: SELECT /*+ SeqScan(t) */ * FROM t; discards the hint as an ordinary comment, making it impossible for downstream tools (query rewriters, proxies, planners) built on `sqlparser-rs` to preserve or act on hints when targeting PostgreSQL. The parser side already handles this via `maybe_parse_optimizer_hint` across SELECT / INSERT / UPDATE / DELETE / MERGE, so no parser or AST changes are required — this is purely a dialect opt-in. The default remains `false`, so no other dialect is affected.
altmannmarcelo
added a commit
to readysettech/datafusion-sqlparser-rs
that referenced
this pull request
Apr 23, 2026
Enable comment-based optimizer hint parsing for the PostgreSQL dialect by overriding `supports_comment_optimizer_hint` to return `true`. PostgreSQL itself does not ship a built-in hint system, but the widely used `pg_hint_plan` extension (https://github.com/ossc-db/pg_hint_plan) introduces hints using the exact same `/*+ ... */` block-comment and `--+ ...` single-line-comment syntax already supported for MySQL and Oracle (apache#2162). Without this flag, parsing a `pg_hint_plan` statement such as: SELECT /*+ SeqScan(t) */ * FROM t; discards the hint as an ordinary comment, making it impossible for downstream tools (query rewriters, proxies, planners) built on `sqlparser-rs` to preserve or act on hints when targeting PostgreSQL. The parser side already handles this via `maybe_parse_optimizer_hint` across SELECT / INSERT / UPDATE / DELETE / MERGE, so no parser or AST changes are required — this is purely a dialect opt-in. The default remains `false`, so no other dialect is affected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this should resolve #1995