Description
When a model is generated (because one is not provided in the JDBC URL), the generated JSON does not properly escape backslashes.
Example in pseudo-code:
Properties info = new Properties(); info.setProperty("schema.jdbcUrl", "jdbc:mssql://host\\THEDB:1443"); DriverManager.getConnection("jdbc:calcite:", info);
Expected result:
The connection is opened successfully.
Actual result:
com.fasterxml.jackson.core.JsonParseException: Unrecognized character escape 'T' (code 84) at [Source: (String)"{ ... "jdbcUrl": "jdbc:mssql://host\THEDB:1443" ... at org.apache.calcite.model.ModelHandler.<init>(ModelHandler.java:101) at org.apache.calcite.jdbc.Driver$1.onConnectionInit(Driver.java:101)
Possible fix:
Add the following to org.apache.calcite.util.JsonBuilder.append(JsonBuilder.java:95). This will fix backslashes but there may be other characters that need to be escaped too.
.replace("\\", "\\\\")
It looks like it's being called by org.apache.calcite.jdbc.Driver$1.model(Driver.java:153).
Attachments
Issue Links
- is duplicated by
-
CALCITE-4893 JsonParseException happens when externalizing expressions with escape character from JSON
- Closed