You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Shengkai Fang <fs...@gmail.com> on 2021/04/20 13:51:00 UTC

Override the CalciteResource.properties

Hi, devs.

Recently I am working around to improve the exception messages when using a
parser to parse meaningless statements in Flink. 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 more straightforward for users to
understand.

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

After the dig, I found 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 annotation 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