Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3583

Support serialized to json and deserialized from json for Exchange relation operator

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None

    Description

      Currently, serialize Exchange relnode to json will cause exception

      // RelWriterTest
      @Test public void testExchange() {
          final FrameworkConfig config = RelBuilderTest.config().build();
          final RelBuilder builder = RelBuilder.create(config);
          final RelNode rel = builder
              .scan("EMP")
              .exchange(RelDistributions.hash(ImmutableList.of(0, 1)))
              .build();
          String relJson = RelOptUtil.dumpPlan("", rel,
              SqlExplainFormat.JSON, SqlExplainLevel.EXPPLAN_ATTRIBUTES);
          String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson);
          final String expected = ""
              + "LogicalExchange(distribution=[hash[0, 1]])\n"
              + "  LogicalTableScan(table=[[scott, EMP]])\n";
          assertThat(s, isLinux(expected));
        }
      

      got

      java.lang.UnsupportedOperationException: type not serializable: hash[0, 1] (type org.apache.calcite.rel.RelDistributions.RelDistributionImpl)
      
      	at org.apache.calcite.rel.externalize.RelJson.toJson(RelJson.java:290)
      	at org.apache.calcite.rel.externalize.RelJsonWriter.put(RelJsonWriter.java:83)
      	at org.apache.calcite.rel.externalize.RelJsonWriter.explain_(RelJsonWriter.java:66)
      	at org.apache.calcite.rel.externalize.RelJsonWriter.done(RelJsonWriter.java:128)
      	at org.apache.calcite.rel.AbstractRelNode.explain(AbstractRelNode.java:299)
      	at org.apache.calcite.plan.RelOptUtil.dumpPlan(RelOptUtil.java:1981)
      	at org.apache.calcite.plan.RelWriterTest.testExchange(RelWriterTest.java:772)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yanlin-Lynn Wang Yanlin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 10m
                  3h 10m