xiangfu0 opened a new pull request, #20319:
URL: https://github.com/apache/pinot/pull/20319

   `CalciteSqlParser.extractQueryOptions` reads SQL options without building an 
AST for the executable statement. Callers that need only the options can reuse 
Pinot's lexer, `SET` grammar, and trailing `OPTION(...)` handling. `SET` takes 
precedence and option names are normalized the same way as in a full parse. The 
broker still validates and executes the query.
   
   ```java
   Map<String, String> options = CalciteSqlParser.extractQueryOptions(
       "SET timeoutMs = 300000; SELECT COUNT(*) FROM events");
   String timeoutMs = options.get("timeoutMs"); // "300000"
   ```
   
   HTTP callers can use `RequestUtils.extractQueryOptions(sql, requestJson)` to 
include JSON `queryOptions` and `trace` with the same `sqlOptionsMode` policy 
as the broker parser.
   
   Use the existing full parser when you need the statement AST, such as for 
table routing. The options-only API supports `SET` both before and after the 
query.
   
   Local JDK 25 comparison for a leading `SET` and a large `IN` list, with 
medians of five measured rounds after three warmups:
   
   | SQL size | Full parse | Options only |
   | --- | ---: | ---: |
   | 150 characters | 39.8 µs | 11.5 µs |
   | 12 KB | 1.64 ms | 0.10 ms |
   | 269 KB | 32.49 ms | 2.14 ms |
   
   All 114 tests across `CalciteSqlCompilerTest` and `SqlOptionsModeTest` 
passed. New tests compare option results with the full parser across syntax and 
precedence cases and exercise extraction from a lexically valid query the full 
parser rejects. Formatting, license, and Checkstyle checks passed for 
`pinot-common`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to