hadoop - Hive UDF String to Date Convertion -
the hive contains table "sample" following data:
15-06-2015 15-06-2015 15-06-2015 15-06-2015 15-06-2015 15-06-2015 16-06-2015
using following query converting string type of data hive date format:
select to_date(from_unixtime(unix_timestamp(date,'dd-mm-yyyy'))) sample;
the output follows:
0 2014-12-28 1 2014-12-28 2 2014-12-28 3 2014-12-28 4 2014-12-28 5 2014-12-28 6 2014-12-28
the output differ expected output.
please suggest how expected output like:
2015-06-15 2015-06-15 2015-06-15 2015-06-15 2015-06-15 2015-06-15 2015-06-16
your problem hiveql case insensitive, second argument of unix_timestamp
function, instead, case sensitive. right syntax query is:
select to_date(from_unixtime(unix_timestamp(date,'dd-mm-yyyy'))) sample;
in way, you'll expected result.
Comments
Post a Comment