slim bouguerra created CALCITE-1765: ---------------------------------------
Summary: Druid adapter fail when the extract granularity is not supported Key: CALCITE-1765 URL: https://issues.apache.org/jira/browse/CALCITE-1765 Project: Calcite Issue Type: Bug Components: druid Affects Versions: 1.12.0 Reporter: slim bouguerra Assignee: Julian Hyde Fix For: 1.13.0 Query like {code} @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(); }{code} will lead to a runtime exception {code} 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){code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)