Skip to content

Associate multi-line comments with their query blocks for implementing Optimizer Hints #1995

@niebayes

Description

@niebayes

Our database is currently implementing an ​Optimizer Hints​ feature similar to MySQL's implementation, using the following syntax:

SELECT /*+ SET_VAR(target_partitions=1) */ * FROM 
    (SELECT /*+ SET_VAR(target_partitions=8) */ * FROM t1 LIMIT 1) AS dt;

In this example, we can identify two distinct query blocks:

  • The inner subquery block
  • The outer main query block

However, we're facing a technical challenge that the current sqlparser library:

  • Automatically ignores all multi-line comments (including our hint syntax)
  • Does not preserve or expose these comments in the parsed statement structure

These limitations make us cannot reliably associate optimizer hints with their corresponding query blocks, which makes it impossible to configure query parameters for each query block solely.

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