deeppatel710 opened a new pull request, #18281:
URL: https://github.com/apache/pinot/pull/18281
## Summary
Adds a lightweight, parse-only syntax validation endpoint to the broker, as
proposed in #17615.
The new `POST /query/sql/validateSyntax` endpoint 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 all `PinotSqlType`
values (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:
```json
POST /query/sql/validateSyntax
{"sql": "SELECT * FROM t WHERE id > 10"}
```
Response (valid):
```json
200 OK
{"valid": true, "sqlType": "DQL"}
```
Response (invalid syntax):
```json
200 OK
{"valid": false, "errorMessage": "..."}
```
Response (missing `sql` field):
```json
400 Bad Request
{"error": "Payload is missing the query string field 'sql'"}
```
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
private `validateSqlSyntax(ObjectNode)` helper.
- `pinot-broker/.../SqlSyntaxValidationResponse.java` — new response POJO
with `valid` / `sqlType` / `errorMessage` fields.
- `pinot-broker/.../PinotClientRequestTest.java` — tests for single-stage
valid, multi-stage valid, invalid syntax, and missing `sql` field.
## Test plan
- [x] Unit tests for single-stage valid query (returns DQL, no error)
- [x] Unit tests for multi-stage valid query (`SET useMultistageEngine=true;
...`)
- [x] Unit tests for invalid SQL (`SELECT FROM WHERE`) — 200 OK with
`valid=false` and error message
- [x] Unit tests for missing `sql` field — 400 Bad Request
- [ ] Manual smoke test against a running broker (reviewer discretion)
Closes #17615
--
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]