MartijnVisser opened a new pull request, #29333:
URL: https://github.com/apache/flink/pull/29333
## What is the purpose of the change
Parse errors that the grammar raises through `SqlUtil.newContextException`,
for example `Non-query expression encountered in illegal context` for `ELECT
1`, reach users without a line or column because `CalciteParser` never read
`SqlParseException#getPos()`. The message now starts with Calcite's own context
wording, as validation errors already do: `SQL parse failed. From line 1,
column 1 to line 1, column 5: Non-query expression encountered in illegal
context`. Line and column are relative to the statement as submitted (leading
comments count, a tab is one column). JavaCC and lexer errors already name
their position and are unchanged.
## Brief change log
- `[hotfix]` extract the `SqlParseException` conversion in `CalciteParser`
into one helper for statements and one for expressions
- `CalciteParser` puts the position in front of the message when the
message does not state it
## Verifying this change
This change added tests and can be verified as follows:
- Added `CalciteParserTest`: ten position cases (misspelled keyword,
`INSERT` and `UNION` bodies, a leading comment, CRLF, tabs, a twenty-line
script, `FROM (t)`, a Flink grammar error, an expression), red on master, and
four cases that pin JavaCC, no-position and EOF behavior
- Extended `ParserImplTest` with an `ELECT 1` spec, red on master
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code (Claude Fable 5.1)
--
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]