Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
None
-
None
-
None
Description
When the expression has escape characters, such as "\r", "\t" and so on, it cannot be externalized correctly. The following test can reproduce the error.
// RelWriterTest.java @Test void testEscapeCharacter() { final FrameworkConfig config = RelBuilderTest.config().build(); final RelBuilder builder = RelBuilder.create(config); final RelNode rel = builder .scan("EMP") .project( builder.call(new MockSqlOperatorTable.SplitFunction(), builder.field("ENAME"), builder.literal("\r"))) .build(); final String relJson = RelOptUtil.dumpPlan("", rel, SqlExplainFormat.JSON, SqlExplainLevel.EXPPLAN_ATTRIBUTES); final String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson); final String expected = "" + "LogicalProject($f0=[SPLIT($1, '\r')])\n" + " LogicalTableScan(table=[[scott, EMP]])\n"; assertThat(s, isLinux(expected)); } FAILURE 3.3sec, org.apache.calcite.plan.RelWriterTest > testEscapeCharacter() java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value at [Source: (String)"{ "rels": [ { "id": "0", "relOp": "LogicalTableScan", "table": [ "scott", "EMP" ], "inputs": [] }, { "id": "1", "relOp": "LogicalProject", "fields": [ "$f0" ], "exprs": [ { "op": { "name": "SPLIT", "kind": "OTHER_FUNCTION", "syntax": "FUNCTION" }, "operands": [ { "input": 1, "name": "$1""[truncated 625 chars]; line: 31, column: 28] at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:193) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:135) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:153) at org.apache.calcite.plan.RelWriterTest.deserializeAndDump(RelWriterTest.java:1006) at org.apache.calcite.plan.RelWriterTest.deserializeAndDumpToTextFormat(RelWriterTest.java:1026) at org.apache.calcite.plan.RelWriterTest.testEscapeCharacter(RelWriterTest.java:978) Caused by: com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value at [Source: (String)"{
Attachments
Issue Links
- duplicates
-
CALCITE-5088 Generated model should escape backslashes
- Closed
- is related to
-
CALCITE-4884 Provide a new constructor for RelJsonWriter to allow customized JsonBuilder
- Closed