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

Stamatis Zampetakis commented on CALCITE-2804:
----------------------------------------------

Hi [~jszeluga], [~michaelmior],

I just run the integration tests, and the test introduced by this PR 
({{DruidAdapterIT#testCastToTimestamp}}) fails with the following message:

{noformat}
java.lang.AssertionError: 
Expected: a string containing 
"{\"queryType\":\"scan\",\"dataSource\":\"foodmart\",\"intervals\":[\"1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z\"]\",\"virtualColumns\":[{\"type\":\"expression\",\"name\":\"vc\",\"expression\":\"timestamp_parse(timestamp_format(\"__time\",\"yyyy-MM-dd\u0027T\u0027HH:mm:ss.SSS\u0027Z\u0027\",\"America/New_York\"),\"yyyy-MM-dd\u0027T\u0027HH:mm:ss.SSS\u0027Z\u0027\",\"UTC\")\",\"outputType\":\"LONG\"}],\"columns\":[\"vc\"],\"resultFormat\":\"compactedList\"}"
     but: was 
"{"queryType":"scan","dataSource":"foodmart","intervals":["1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z"],"virtualColumns":[{"type":"expression","name":"vc","expression":"timestamp_parse(timestamp_format(\"__time\",'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','America/New_York'),'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','UTC')","outputType":"LONG"}],"columns":["vc"],"resultFormat":"compactedList"}"
Expected :a string containing 
"{\"queryType\":\"scan\",\"dataSource\":\"foodmart\",\"intervals\":[\"1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z\"]\",\"virtualColumns\":[{\"type\":\"expression\",\"name\":\"vc\",\"expression\":\"timestamp_parse(timestamp_format(\"__time\",\"yyyy-MM-dd\u0027T\u0027HH:mm:ss.SSS\u0027Z\u0027\",\"America/New_York\"),\"yyyy-MM-dd\u0027T\u0027HH:mm:ss.SSS\u0027Z\u0027\",\"UTC\")\",\"outputType\":\"LONG\"}],\"columns\":[\"vc\"],\"resultFormat\":\"compactedList\"}"
Actual   
:"{"queryType":"scan","dataSource":"foodmart","intervals":["1900-01-09T00:00:00.000Z/2992-01-10T00:00:00.000Z"],"virtualColumns":[{"type":"expression","name":"vc","expression":"timestamp_parse(timestamp_format(\"__time\",'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','America/New_York'),'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','UTC')","outputType":"LONG"}],"columns":["vc"],"resultFormat":"compactedList"}"
{noformat}

Do you have any ideas why? I don't know if it is relevant but the current vm 
uses druid version 0.14.0-incubating.



> Druid adapter: Cast does not work when casting to timestamp
> -----------------------------------------------------------
>
>                 Key: CALCITE-2804
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2804
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.18.0
>            Reporter: Justin Szeluga
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.20.0
>
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> When trying to execute a simple statement of 
> {code:java}
> select cast("__time" as timestamp) from my_datasource limit 10;{code}
> the query fails with a 500 error
>  
> {code:java}
> Caused by: java.io.IOException: Server returned HTTP response code: 500 for 
> URL: http://localhost:58082/druid/v2/?pretty
> at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
> at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
> at org.apache.calcite.runtime.HttpUtils.executeMethod(HttpUtils.java:137)
> at org.apache.calcite.runtime.HttpUtils.post(HttpUtils.java:110)
> at 
> org.apache.calcite.adapter.druid.DruidConnectionImpl.request(DruidConnectionImpl.java:109)
> ... 29 more
> {code}
> because the JSON generated is incorrect. Here is the generated JSON
>  
>  
> {code:java}
> {
>   "queryType": "scan",
>   "dataSource": "my_datasource",
>   "intervals": [
>     "1900-01-01T00:00:00.000Z/3000-01-01T00:00:00.000Z"
>   ],
>   "virtualColumns": [
>     {
>       "type": "expression",
>       "name": "vc",
>       "expression": 
> "timestamp_parse(timestamp_format(\"__time\",'yyyy-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','America/New_York'),'','UTC')",
>       "outputType": "LONG"
>     }
>   ],
>   "columns": [
>     "vc"
>   ],
>   "resultFormat": "compactedList",
>   "limit": 10
> }
> {code}
> There are two problems. -First, the "__time" dimension is not formatted 
> correctly in timestamp_format. The escaped quotes need to be removed.-
> Also, the call to timestamp_parse is incorrect. If a timezone is going to be 
> provided then a date time format needs to be provided as well. Currently, it 
> is only empty string
>  
>  



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

Reply via email to