Hi, devs.

Recently I am working around to improve the exception messages when using
parser to parse meaningless statement. For example,

```
parser.parse("INVALID COMMAND");
```
we will get the cause

```
org.apache.flink.table.api.SqlParserException: SQL parse failed. Non-query
expression encountered in illegal context
```

I think `Unsupprorted input statement` is much more straighforward for usrs
to understand.

So my goal is to find  how we can define the user-defined exception
message, i.e. define exception message for
`CalciteResource#illegalNonQueryExpression`.

After the dig, I find the `org.apache.calcite.runtime.Resources#create`
will try to load the content of  `CalciteResource.properties` to define the
exception message. If the `CalciteResource.properties` is not found or not
found the key in the file, it will use the anotation as the exception
message. The logic is located at
`org.apache.calcite.runtime.Resources$Inst#raw`

My solution to solve the problem is to override the
CalciteResources.properties and add the expected exception message in the
new CalciteResources.properties.

However, the new CalciteResources.properties doesn't `extend` the old
CalciteResources.properties. That is we lose other error messages that are
defined in the origin CalciteResources.properties. Do we need to copy the
origin content into the new file and modify the message we want to modify?

Look forward to your feedback.

Best,
Shengkai

Reply via email to