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

Hongze Zhang commented on CALCITE-2933:
---------------------------------------

[~krisden] - I didn't see the root cause till now, but I'm sure the issue 
should be limited to the Druid adapter.

After the fix of CALCITE-2590 or CALCITE-2695, the expression 
{{cast(cast("timestamp" as timestamp) as varchar)}} is simplified to 
{{cast("timestamp" as varchar)}}. Then code near the method[1] from 
{{DruidQuery.java}} translates the logical plan to different Druid query which 
produces different result with what's produced before.


[1] 
[https://github.com/apache/calcite/blob/1229ef27094ea73ad9c7a397f442285c7e1df9b0/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java#L752]

> In Druid adapter, expression like "cast(cast(\"timestamp\" as timestamp) as 
> varchar)" returns as epoch millisecond
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2933
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2933
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.18.0
>            Reporter: Hongze Zhang
>            Assignee: Danny Chan
>            Priority: Major
>
> SQL 1:
> {code}
> select cast("timestamp" as timestamp) as t from "foodmart" order by t limit 1
> {code}
> Result:
> {code}
> T=1997-01-01 00:00:00
> {code}
> SQL 2:
> {code}
> select cast(cast("timestamp" as timestamp) as varchar) as t from "foodmart" 
> order by t limit 1
> {code}
> Result:
> {code}
> T=852076800000
> {code}
> The second query should returns with the same format as the first one.
> See test case:
> https://github.com/apache/calcite/blob/master/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT2.java#L3937-L3946



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

Reply via email to