feat: complete SQL Server OPTION query hint support - #2486
Merged
manticore-projects merged 1 commit intoAug 19, 2026
Conversation
manticore-projects
requested changes
Aug 18, 2026
| * <a href="https://learn.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query">Hints | ||
| * (Transact-SQL) - Query Hints</a>. | ||
| */ | ||
| public class UnknownVariable extends ASTNodeAccessImpl implements Expression { |
Contributor
There was a problem hiding this comment.
Do we really need an extra class for this? Why not just carry a normal "Identifier" or "String" along? I would love to avoid especially the extra methods in the Visitors.
Contributor
Author
There was a problem hiding this comment.
Replaced UnknownVariable with a table-less Column and removed the class plus every Visitor addition. Column#getColumnName() retains @p UNKNOWN.
fudianchn
marked this pull request as draft
August 19, 2026 07:14
Attach OPTION to MERGE statements and validate and deparse its parameters. Parse OPTIMIZE FOR (@variable UNKNOWN) as a table-less Column, reusing the existing expression visitor contract. Reject OPTION after standalone VALUES, including INSERT ... VALUES, because SQL Server allows query hints on INSERT only in a nested SELECT. Preserve exact spacing when MERGE combines OUTPUT and OPTION. Signed-off-by: 付典 <fudianchn@gmail.com>
fudianchn
force-pushed
the
feat/option-hints-followup
branch
from
August 19, 2026 07:42
1157f74 to
bf17921
Compare
fudianchn
marked this pull request as ready for review
August 19, 2026 07:44
Contributor
|
Thank you, I like this more. |
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.
Description
Completes two SQL Server
OPTIONfollow-ups from #2472:OPTION (...)afterMERGE, including afterOUTPUT.OPTIMIZE FOR (@variable UNKNOWN)as an existing table-lessColumn, avoiding a new expression type and Visitor methods.Also reject
OPTIONafter standaloneVALUES, includingINSERT ... VALUES, because SQL Server permits query hints onINSERTonly in its nestedSELECT.INSERT ... SELECT ... OPTIONremains supported.Testing
OptionClauseTest: 19/19 passed. New cases coverMERGE,OUTPUT,OPTIMIZE FOR, invalidINSERT ... VALUESand validINSERT ... SELECTforms.Performance
JSQLParserBenchmark.parseSQLStatementsonperformance.sql,version=latest, JDK 17.0.20, 10 forks x (3 warmup + 10 measurement iterations), 100 samples per run, two interleaved runs per build on a 32-thread Intel Core i9-13900KS host:7013909bf17921Mean delta: +0.15%. All confidence intervals overlap -> no regression.