Skip to content

add support for SQL Server Query Hints #161

Closed

Description

@donshop11

the following query does not parse:

SELECT CustomerID, PersonID, StoreID
FROM cte
OPTION (MAXRECURSION 2);

see description here:
https://msdn.microsoft.com/en-us/library/ms181714.aspx

The value inside the OPTION is not that important to parse, it is more important not to fail parsing this kind of statements.

Activity

  1. fudianchn commented on Aug 15, 2026

    @fudianchn
    Contributor

    Root cause: the grammar has no production for the T-SQL OPTION (...) query hint clause, so any statement carrying one fails to parse.

    PR #2472 adds it: OPTION (...) at the end of SELECT (including after set operations and FOR XML), UPDATE and DELETE parses into a new OptionClause holding OptionHints (keyword name + optional value or argument list). The statement from this issue parses into PlainSelect with MAXRECURSION 2 accessible from the AST and deparse round-trips unchanged; all query hint forms currently documented by Microsoft parse as well, and option stays a non-reserved keyword usable as column and table name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions