Compute differences between succesive records in Hadoop with Hive Queries

前端 未结 3 1594
后悔当初
后悔当初 2021-01-12 04:26

I have a Hive table that holds data of customer calls. For simplicity consider it has 2 columns, first column holds the customer ID and the second column holds the timestamp

3条回答
  •  臣服心动
    2021-01-12 05:15

    It's an old question, but for future references, I write here another proposition:

    Hive Windowing functions allows to use previous / next values in your query.

    A similar code query may be :

    SELECT customer_id, call_time - LAG(call_time, 1, 0) OVER (PARTITION BY customer_id ORDER BY call_time) FROM mytable;
    

提交回复
热议问题