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

RelJson should throw if asked to deserialize a call to an unknown operator

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.28.0
    • None

    Description

      Currently, when deserialize a RexNode fails, calcite returns a null value, causing NPE in somewhere else. So we cannot get any information about the SqlOperator in the stacktrace.  This makes it hard to determine the reason when deserialize a very long json string.

      Caused by: java.lang.NullPointerException
      	at java.util.Objects.requireNonNull(Objects.java:203)
      	at org.apache.calcite.rel.core.AggregateCall.<init>(AggregateCall.java:98)
      	at org.apache.calcite.rel.core.AggregateCall.create(AggregateCall.java:198)
      	at org.apache.calcite.rel.externalize.RelJsonReader.toAggCall(RelJsonReader.java:289)
      	at org.apache.calcite.rel.externalize.RelJsonReader.access$500(RelJsonReader.java:59)
      	at org.apache.calcite.rel.externalize.RelJsonReader$2.getAggregateCalls(RelJsonReader.java:172)
      	at org.apache.calcite.rel.core.Aggregate.<init>(Aggregate.java:220)
      	at org.apache.calcite.rel.logical.LogicalAggregate.<init>(LogicalAggregate.java:105)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.apache.calcite.rel.externalize.RelJsonReader.readRel(RelJsonReader.java:264)
      	at org.apache.calcite.rel.externalize.RelJsonReader.readRels(RelJsonReader.java:91)
      	at org.apache.calcite.rel.externalize.RelJsonReader.read(RelJsonReader.java:85)
      	at org.apache.calcite.plan.RelWriterTest.lambda$deserializeAndDumpToTextFormat$6(RelWriterTest.java:894)
      	at org.apache.calcite.tools.Frameworks.lambda$withPlanner$0(Frameworks.java:131)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:914)
      	at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:180)
      	... 67 more
      

      Maybe it's better to throw exception instead of return null, adding the name, kind, and syntax in the error message

      Attachments

        Issue Links

          Activity

            People

              yanlin-Lynn Wang Yanlin
              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 - 4h 10m
                  4h 10m