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 <[email protected]> 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 [email protected] > 215-701-3146 > >
