drill-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andries Engelbrecht <aengelbre...@maprtech.com>
Subject Re: convert unix timestamp
Date Fri, 29 May 2015 20:40:28 GMT
Good call Kristine!!!

Seems to_timestamp is the better way to go that using from_unixtime.

select date_part('hour', to_timestamp(1432912733)) from `sys`.`version`;
+---------+
| EXPR$0  |
+---------+
| 15      |
+---------+
1 row selected (0.171 seconds)


—Andries


On May 29, 2015, at 1:22 PM, Kristine Hahn <khahn@maprtech.com> wrote:

> I think TO_TIMESTAMP is what you're looking for. Please see
> http://drill.apache.org/docs/data-type-conversion/#to_timestamp.
> 
> Kristine Hahn
> Sr. Technical Writer
> 415-497-8107 @krishahn
> 
> 
> On Fri, May 29, 2015 at 11:40 AM, Christopher Matta <cmatta@mapr.com> wrote:
> 
>> I need to be able to convert a unix timestamp to a drill timestamp.
>> 
>> I can use the from_unixtime function return what seems like a timestamp, or
>> a string formatted correctly, however it seems like it doesn’t return it as
>> a string or as a timestamp type:
>> 
>> 0: jdbc:drill:zk=sen11:5181,sen12:5181> select
>> from_unixtime(1432912733) from `sys`.`version`;
>> +----------------------+
>> |        EXPR$0        |
>> +----------------------+
>> | 2015-05-29 15:18:53  |
>> +----------------------+
>> 1 row selected (0.134 seconds)
>> 
>> Trying to run date-specific functions on the result:
>> 
>> 0: jdbc:drill:zk=sen11:5181,sen12:5181> select datepart('hour',
>> from_unixtime(1432912733)) from `sys`.`version`;
>> Error: PARSE ERROR: From line 1, column 8 to line 1, column 50: No
>> match found for function signature datepart(<CHARACTER>, <ANY>)
>> 
>> [Error Id: aa906f4b-fa49-4a3d-9a7c-0063c7c6c97b on
>> se-node10.se.lab:31010] (state=,code=0)
>> 
>> Trying to cast it to a timestamp returns an error:
>> 
>> 0: jdbc:drill:zk=sen11:5181,sen12:5181> select
>> CAST(from_unixtime(1432912733) as TIMESTAMP) from `sys`.`version`;
>> Error: SYSTEM ERROR:
>> org.apache.drill.exec.exception.SchemaChangeException: Failure while
>> trying to materialize incoming schema.  Errors:
>> 
>> Error in expression at index -1.  Error: Missing function
>> implementation: [castBIGINT(VAR16CHAR-OPTIONAL)].  Full expression:
>> --UNKNOWN EXPRESSION--..
>> 
>> Fragment 0:0
>> 
>> [Error Id: 7e75d4b9-a478-40cd-80b4-fda27815b9ef on
>> se-node10.se.lab:31010] (state=,code=0)
>> 
>> Any ideas?
>> 
>> Chris Mattacmatta@mapr.com
>> 215-701-3146
>> ​
>> 


Mime
View raw message