You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/08/18 09:46:38 UTC

[GitHub] [calcite] liyafan82 commented on a change in pull request #2110: [CALCITE-4177] Throw exception when deserialize SqlOperator fails, do not return null

liyafan82 commented on a change in pull request #2110:
URL: https://github.com/apache/calcite/pull/2110#discussion_r472054313



##########
File path: core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
##########
@@ -1131,6 +1132,36 @@ private RelNode mockCountOver(String table,
     assertThat(s, isLinux(expected));
   }
 
+  @Test void testDeserializeInvalidOperatorName() {
+    final FrameworkConfig config = RelBuilderTest.config().build();
+    final RelBuilder builder = RelBuilder.create(config);
+    final RelNode rel = builder
+        .scan("EMP")
+        .project(
+            builder.field("JOB"),
+            builder.field("SAL"))
+        .aggregate(
+            builder.groupKey("JOB"),
+            builder.max("max_sal", builder.field("SAL")),
+            builder.min("min_sal", builder.field("SAL")))
+        .project(
+            builder.field("max_sal"),
+            builder.field("min_sal"))
+        .build();
+    final RelJsonWriter jsonWriter = new RelJsonWriter();
+    rel.explain(jsonWriter);
+    // mock a non exist SqlOperator
+    String relJson = jsonWriter.asString().replace("\"name\": \"MAX\"", "\"name\": \"MAXS\"");
+    try {
+      deserializeAndDumpToTextFormat(getSchema(rel), relJson);
+      fail();
+    } catch (Exception e) {

Review comment:
       Maybe we should catch CalciteException here?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org