0

Hive's hour function returns NULL. below is my query

select hour(col_name) from hivetable

datatype for col_name is string and value is in format HH:MM:SS

Vish
  • 1
  • 1

2 Answers2

0

I would suggest you to check the col_name format is correct, either it should have a timestamp format or as 'HH:mm:ss', because using 'hour' function on string time will work. example: hour('HH:mm:ss')

hive > select hour('12:58:59') as hour;
OK
hour
12
Time taken: 0.061 seconds, Fetched: 1 row(s)
user7343922
  • 316
  • 4
  • 17
0

The issue can be resolved by using select hour(from_unixtime(unix_timestamp(col_name, 'HH:mm:ss')) from hivetable.

But i am not sure why we need to do this when the input value is string and in correct format which is "HH:mm:ss"

Vish
  • 1
  • 1