Skip to content
Advertisement

Hive SQL – time interval in 5 minutes

My data is too large to analyze since it is collecting every second or so. To reduce the data, I will like to group into interval of 5 minutes. I tried converting into unix timestamp and reverting it back, but didn’t work.

I tried something like this

Original data or output

Desired output

Advertisement

Answer

I don’t know Hive, but make sure that the division is an integr division truncating fractions, and then multiply back, losing the last fractional 300 seconds in the process:

If Hive Sql does not truncate (upon integer division by 300) you have to use a function like FLOOR to do so.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement