sql - Apache Hive: converting timestamp from string to timestamp and save it table -



sql - Apache Hive: converting timestamp from string to timestamp and save it table -

i have table in hbase: tableexaple (timestamp, timestamp_string, someotherstuff)

timestamp has datatype timestamp timestamp_string hast datatype string , has pattern 'yyyy-mm-dd hh:mm:ss.sss'

now read value timestamp_string convert hive-udf unix_timestamp(string date, string pattern) timestamp , save in same table value timestamp.

how can this?

stuff like

insert tableexaple (timestamp) select unix_timestamp(timestamp_string, 'yyyy-mm-dd hh:mm:ss.sss') tableexaple;

does not work.

i don't think unix_timestamp likes millisecond format. since timestamp_string of type string, can split on '.' , grab date , time. if had 2014-11-11 08:09:10.123, split(timestamp_string, '\\.') give [2014-11-11 08:09:10, 123]. can reference array [0] , [1].

example:

select otherstuff , timestamp , unix_timestamp(split(timestamp_string, '\\.')[0], 'yyyy-mm-dd hh:mm:ss') new_time some_table

if want include milliseconds in new_time column, grab [1]th index split array (and split 1000).

sql hadoop hive sql-insert

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -