Add POST /query/sql/validateSyntax broker endpoint#18281
Add POST /query/sql/validateSyntax broker endpoint#18281deeppatel710 wants to merge 1 commit intoapache:masterfrom
Conversation
Adds a lightweight, parse-only syntax validation endpoint to the broker. It runs the query through Pinot's Calcite-based SQL parser (RequestUtils.parseQuery) without consulting table metadata, performing semantic validation, or executing the query. Supports both single-stage and multi-stage queries and all PinotSqlType values (DQL/DML/DDL/DCL). The endpoint returns HTTP 200 with a SqlSyntaxValidationResponse body for both valid and invalid queries; clients inspect the `valid` flag and `errorMessage` to distinguish. HTTP 400 is returned only when the request payload is missing the `sql` field. The motivation (per issue apache#17615) is to let operators detect parser regressions early in Calcite upgrade cycles -- similar to the one seen in apache#16295 -- by replaying a corpus of queries against a canary broker without needing any table setup or query execution.
|
@Jackie-Jiang would you have a chance to take a look when you get a moment? This adds the parse-only |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18281 +/- ##
============================================
+ Coverage 63.59% 63.66% +0.07%
Complexity 1658 1658
============================================
Files 3243 3244 +1
Lines 197343 197373 +30
Branches 30547 30548 +1
============================================
+ Hits 125494 125658 +164
+ Misses 61814 61673 -141
- Partials 10035 10042 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Adds a lightweight, parse-only syntax validation endpoint to the broker, as proposed in #17615.
The new
POST /query/sql/validateSyntaxendpoint runs the query through Pinot's Calcite-based SQL parser (RequestUtils.parseQuery) without consulting table metadata, performing semantic validation, or executing the query. It supports both single-stage and multi-stage queries and allPinotSqlTypevalues (DQL/DML/DDL/DCL).Motivation
Per #17615: Calcite upgrades occasionally introduce new reserved keywords that cause parse failures against previously-valid queries (see #16295 for a prior incident). This endpoint lets operators replay a corpus of queries against a canary broker to detect parser regressions before rolling a new Calcite version into production, without needing any table setup, schema, or query execution.
There are related endpoints, but none solve this use case:
POST /query/sql/queryFingerprint(broker) — parses but also generates a fingerprint, and only accepts DQL.POST /validateMultiStageQuery(controller) — does more than parsing and is multi-stage-only.Contract
Request:
Response (valid):
Response (invalid syntax):
Response (missing
sqlfield):Design note: both valid and invalid parse outcomes return HTTP 200 with the result in the body. This keeps clients from having to distinguish transport errors from parse errors when replaying query corpuses at scale. 4xx/5xx are reserved for malformed requests and uncaught server errors.
Changes
pinot-broker/.../PinotClientRequest.java— new endpoint method and privatevalidateSqlSyntax(ObjectNode)helper.pinot-broker/.../SqlSyntaxValidationResponse.java— new response POJO withvalid/sqlType/errorMessagefields.pinot-broker/.../PinotClientRequestTest.java— tests for single-stage valid, multi-stage valid, invalid syntax, and missingsqlfield.Test plan
SET useMultistageEngine=true; ...)SELECT FROM WHERE) — 200 OK withvalid=falseand error messagesqlfield — 400 Bad RequestCloses #17615