GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: complete SQL Server OPTION query hint support by fudianchn · Pull Request #2486 · JSQLParser/JSqlParser

Conversation

@fudianchn

@fudianchn fudianchn commented Aug 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

Completes two SQL Server OPTION follow-ups from #2472:

  1. Parse, retain, validate and deparse OPTION (...) after MERGE, including after OUTPUT.
  2. Parse OPTIMIZE FOR (@variable UNKNOWN) as an existing table-less Column, avoiding a new expression type and Visitor methods.

Also reject OPTION after standalone VALUES, including INSERT ... VALUES, because SQL Server permits query hints on INSERT only in its nested SELECT. INSERT ... SELECT ... OPTION remains supported.

Testing

OptionClauseTest: 19/19 passed. New cases cover MERGE, OUTPUT, OPTIMIZE FOR, invalid INSERT ... VALUES and valid INSERT ... SELECT forms.

Performance

JSQLParserBenchmark.parseSQLStatements on performance.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:

build run 1 (ms/op) run 2 (ms/op)
base 7013909 3.724 ± 0.026 3.717 ± 0.023
this PR bf17921 3.714 ± 0.022 3.738 ± 0.025

Mean delta: +0.15%. All confidence intervals overlap -> no regression.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
manticore-projects
manticore-projects requested changes Aug 18, 2026
View reviewed changes
Comment thread src/main/java/net/sf/jsqlparser/expression/UnknownVariable.java Outdated
* <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 {

@manticore-projects manticore-projects Aug 18, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fudianchn fudianchn Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced UnknownVariable with a table-less Column and removed the class plus every Visitor addition. Column#getColumnName() retains @p UNKNOWN.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/test/java/net/sf/jsqlparser/statement/select/OptionClauseTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@fudianchn
fudianchn marked this pull request as draft August 19, 2026 07:14
@fudianchn
feat: complete SQL Server OPTION query hint support
bf17921
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: 付典 <[email protected]>
@fudianchn
fudianchn force-pushed the feat/option-hints-followup branch from 1157f74 to bf17921 Compare August 19, 2026 07:42
@fudianchn fudianchn changed the title feat: support OPTION hints after MERGE and INSERT ... VALUES, and the OPTIMIZE FOR (@var UNKNOWN) parameter form feat: complete SQL Server OPTION query hint support Aug 19, 2026
@fudianchn
fudianchn marked this pull request as ready for review August 19, 2026 07:44
@manticore-projects

manticore-projects commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Thank you, I like this more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects
manticore-projects merged commit 4c6a4fb into JSQLParser:master Aug 19, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@fudianchn
fudianchn deleted the feat/option-hints-followup branch August 21, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@manticore-projects manticore-projects manticore-projects requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@fudianchn @manticore-projects
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.