[ 
https://issues.apache.org/jira/browse/CALCITE-2782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16743110#comment-16743110
 ] 

Jesus Camacho Rodriguez edited comment on CALCITE-2782 at 1/15/19 2:39 PM:
---------------------------------------------------------------------------

You can pass a property value for 'timeZone' in the JDBC connection string.
bq. I have never had to manually set a timezone in the driver properties of any 
driver before.
I just checked the code in CalciteConnectionProperty and it is mentioned that 
the default should be the JVM's time zone though we are setting the default to 
null, that may be a bug:
https://github.com/apache/calcite/blame/master/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java#L132
In addition, I want to mention that Druid handler accepts both TIMESTAMP and 
TIMESTAMP WITH LOCAL TIME ZONE semantics for the time column (in case you just 
need the former without any time zone involved).
https://calcite.apache.org/docs/druid_adapter.html
https://github.com/apache/calcite/blob/master/druid/src/main/java/org/apache/calcite/adapter/druid/DruidTableFactory.java#L69


was (Author: jcamachorodriguez):
You can pass a property value for 'timeZone' in the JDBC connection string.
bq. I have never had to manually set a timezone in the driver properties of any 
driver before.
I just checked the code in CalciteConnectionProperty and it is mentioned that 
the default should be the JVM's time zone though we are setting the default to 
null:
https://github.com/apache/calcite/blame/master/core/src/main/java/org/apache/calcite/config/CalciteConnectionProperty.java#L132
In addition, I want to mention that Druid handler accepts both TIMESTAMP and 
TIMESTAMP WITH LOCAL TIME ZONE semantics for the time column (in case you just 
need the former without any time zone involved).
https://calcite.apache.org/docs/druid_adapter.html
https://github.com/apache/calcite/blob/master/druid/src/main/java/org/apache/calcite/adapter/druid/DruidTableFactory.java#L69

> EXTRACT function doesn't work because of NULL returned from 
> druidQuery.getConnectionConfig().timeZone()
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2782
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2782
>             Project: Calcite
>          Issue Type: Bug
>          Components: druid
>    Affects Versions: 1.18.0
>            Reporter: Justin Szeluga
>            Assignee: Julian Hyde
>            Priority: Major
>
> The default value for BuiltInConnectionProperty.TIME_ZONE is null. If the 
> timezone is not set in the properties then the null is returned and a 
> NullPointerException is thrown when PeriodGranularity initializes.
> {code:java}
> Caused by: java.lang.RuntimeException: Error while applying rule 
> DruidProjectRule, args 
> [rel#303:LogicalProject.NONE.[](input=RelSubset#145,EXPR$0=EXTRACT(FLAG(DAY), 
> $0)), rel#213:DruidQuery.BINDABLE.[](table=[adhoc, 
> bach.sign_ctrl_f],intervals=[2019-01-08T00:00:00.000Z/3000-01-01T00:00:00.000Z])]
>     at 
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:236)
>     at 
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:641)
>     at org.apache.calcite.tools.Programs.lambda$standard$3(Programs.java:298)
>     at 
> org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:358)
>     at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:189)
>     at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:320)
>     at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:231)
>     at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:772)
>     at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:636)
>     at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:606)
>     at 
> org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:229)
>     at 
> org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:550)
>     at 
> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675)
>     at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
>     ... 14 more
> Caused by: java.lang.NullPointerException
>     at java.util.Objects.requireNonNull(Unknown Source)
>     at 
> org.apache.calcite.adapter.druid.Granularities$PeriodGranularity.<init>(Granularities.java:93)
>     at 
> org.apache.calcite.adapter.druid.Granularities$PeriodGranularity.<init>(Granularities.java:85)
>     at 
> org.apache.calcite.adapter.druid.Granularities.createGranularity(Granularities.java:57)
>     at 
> org.apache.calcite.adapter.druid.DruidDateTimeUtils.extractGranularity(DruidDateTimeUtils.java:331)
>     at 
> org.apache.calcite.adapter.druid.DruidQuery.toDruidColumn(DruidQuery.java:273)
>     at 
> org.apache.calcite.adapter.druid.DruidQuery.computeProjectAsScan(DruidQuery.java:763)
>     at 
> org.apache.calcite.adapter.druid.DruidRules$DruidProjectRule.onMatch(DruidRules.java:298)
>     at 
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:212)
>     ... 27 more
> {code}
> In tests, org.apache.calcite.test.CalciteAssert#assertQuery sets the timezone 
> to UTC hiding the problem. When I issue queries from DBeaver it fails because 
> of the NPE



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to