Skip to content
Advertisement

Combining Aggregate Function with resampling in Impala

I have Table in Hadoop in which I have data for different sensor units with a sampling time ts of 1 mSec. I can resample the data for a single unit with a combination of different aggregate functions using the following query in Impala (Let’s say I want to resample the data for each 5 minute using LAST_VALUE() as aggregate function):

If I am running this query for a single unit then I am getting the correct asnwer and there is no issue.

But if I want to resample the data for each Unit based on some aggregation function e.g. LAST_VALUE() then I am getting the wrong answer and resample result for each unit is same although I have different data for each unit. The query that I am running is given below where I am not specifying any unit in WHERE clause:

The result obtained using the above query for present three units in the data is given below:

Actually I want ot get the last value for each unit that is different for each unit. Like below:

Could anybody tell me that what is the problem in my query ?

Thanks

Advertisement

Answer

I solved this problem by giving unit information in the partition by with ts_resample. The final solution is given below:

After this I have the result as I wanted and showed in my question.

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