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

Druid adapter fail when the extract granularity is not supported

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.12.0
    • Fix Version/s: 1.13.0
    • Component/s: druid
    • Labels:
      None

      Description

      Query like

       @Test public void testNotAcceptedKindOfExtract() {
          final String sql = "SELECT extract(week from \"timestamp\") from \"foodmart\" where "
              + "\"product_id\" = 1558 group by extract(week from \"timestamp\")";
          sql(sql).runs();
        }

      will lead to a runtime exception

       ava.lang.AssertionError: not a json object: null
      
      	at org.apache.calcite.adapter.druid.DruidQuery.writeObject(DruidQuery.java:860)
      	at org.apache.calcite.adapter.druid.DruidQuery.writeArray(DruidQuery.java:840)
      	at org.apache.calcite.adapter.druid.DruidQuery.writeObject(DruidQuery.java:856)
      	at org.apache.calcite.adapter.druid.DruidQuery.writeField(DruidQuery.java:826)
      	at org.apache.calcite.adapter.druid.DruidQuery.getQuery(DruidQuery.java:729)
      	at org.apache.calcite.adapter.druid.DruidQuery.deriveQuerySpec(DruidQuery.java:479)
      	at org.apache.calcite.adapter.druid.DruidQuery.getQuerySpec(DruidQuery.java:428)
      	at org.apache.calcite.adapter.druid.DruidQuery.deriveRowType(DruidQuery.java:322)
      	at org.apache.calcite.rel.AbstractRelNode.getRowType(AbstractRelNode.java:224)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.register(VolcanoPlanner.java:857)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:883)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.ensureRegistered(VolcanoPlanner.java:1769)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.transformTo(VolcanoRuleCall.java:135)
      	at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:225)
      	at org.apache.calcite.adapter.druid.DruidRules$DruidAggregateProjectRule.onMatch(DruidRules.java:448)
      	at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:211)
      	at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650)
      	at org.apache.calcite.tools.Programs$5.run(Programs.java:326)
      	at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:387)
      	at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:162)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:295)
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:204)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:783)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:639)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:609)
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214)
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:595)
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:615)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:148)
      	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
      	at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:511)
      	at org.apache.calcite.test.CalciteAssert$AssertQuery.queryContains(CalciteAssert.java:1422)
      	at org.apache.calcite.test.DruidAdapterIT.testNotAcceptedKindOfExtract(DruidAdapterIT.java:1996)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

        Activity

        Show
        bslim slim bouguerra added a comment - https://github.com/apache/calcite/pull/437
        Hide
        julianhyde Julian Hyde added a comment -

        I've added some review comments.

        Show
        julianhyde Julian Hyde added a comment - I've added some review comments.
        Hide
        julianhyde Julian Hyde added a comment -
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/a377f8f2 . Thanks for the PR, slim bouguerra !
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.13.0 (2017-06-26).

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.13.0 (2017-06-26).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            bslim slim bouguerra
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development