HIVE function - by date

Can someone tell me why I don't get bills for every group f0, MONTH, DAY, HOUR, MINUTE in my result set?

Result set:

result set

Query:

SELECT t.f0, MONTH(TO_DATE(Hex2Dec(t.f2))), DAY(TO_DATE(Hex2Dec(t.f2))), HOUR(TO_DATE(Hex2Dec(t.f2))), MINUTE(TO_DATE(Hex2Dec(t.f2))), COUNT(DISTINCT t.f1) FROM table t WHERE (t.f0 = 1 OR t.f0 = 2) AND (t.f3 >= '2013-02-06' AND t.f3 < '2013-02-15') AND (Hex2Dec(t.f2) >= 1360195200 AND Hex2Dec(t.f2) < 1360800000) AND *EXTRA CONDITIONS* GROUP BY t.f0, MONTH(TO_DATE(Hex2Dec(t.f2))), DAY(TO_DATE(Hex2Dec(t.f2))), HOUR(TO_DATE(Hex2Dec(t.f2))), MINUTE(TO_DATE(Hex2Dec(t.f2))) 

Scheme:

f0 INT (partition column)
f1 INT
f2 STRING
f3 STRING (section column)
f4 STRING
f5 STRING
f6 STRING
f7 MAP <STRING,STRING>

* f2 is a unix timestamp in hexadecimal format

+7
source share
1 answer

This may be due to the fact that to_date returns null when it is applied in unix time.
In accordance with the instructions for use :

to_date (string timestamp):
Returns the portion of the timestamp date string: to_date ("1970-01-01 00:00:00") = "1970-01-01"

Use from_unixtime to return the correct date details.

Note:
I assume Hex2Dec UDF is taken from the HIVE-1545 core library

+10
source

All Articles