복붙노트

[HADOOP] Hive에서 15 분 미만의 날짜 차이

HADOOP

Hive에서 15 분 미만의 날짜 차이

아래는 내 쿼리이며, 마지막 줄에서 날짜 사이의 차이가 15 분 이내인지 확인하려고합니다. 그러나 아래 쿼리를 실행할 때마다

SELECT TT.BUYER_ID , COUNT(*) FROM
(SELECT testingtable1.buyer_id, testingtable1.item_id, testingtable1.created_time from (select user_id, prod_and_ts.product_id as product_id, prod_and_ts.timestamps as timestamps from testingtable2 LATERAL VIEW explode(purchased_item) exploded_table as prod_and_ts where to_date(from_unixtime(cast(prod_and_ts.timestamps as BIGINT))) = '2012-07-09') prod_and_ts RIGHT OUTER JOIN (SELECT buyer_id, item_id, rank(buyer_id), created_time, UNIX_TIMESTAMP(created_time)
FROM (
    SELECT buyer_id, item_id, created_time
    FROM testingtable1
    where to_date(from_unixtime(cast(UNIX_TIMESTAMP(created_time) as int))) = '2012-07-09'
    DISTRIBUTE BY buyer_id
    SORT BY buyer_id, created_time desc
) a
WHERE rank(buyer_id) < 5) testingtable1 ON (testingtable1.item_id = prod_and_ts.product_id AND testingtable1.BUYER_ID = prod_and_ts.USER_ID 
AND abs(datediff(testingtable1.created_time,FROM_UNIXTIME(cast(prod_and_ts.timestamps as BIGINT)))) <= 15) where prod_and_ts.product_id IS NULL ORDER BY testingtable1.buyer_id, testingtable1.created_time desc) TT GROUP BY TT.BUYER_ID;

나는 항상 예외를 얻는다.

FAILED: Error in semantic analysis: line 10:144 Both Left and Right Aliases
Encountered in Join 15

내 질문에 문제가 있습니까? 또는 Hive에서 날짜 간 차이를 분 단위로 계산할 수 없습니까? 모든 제안을 부탁드립니다.

해결법

  1. ==============================

    1.문제는 당신의 가입에 있다고 생각합니다. Hive 언어 매뉴얼에서 :

    문제는 당신의 가입에 있다고 생각합니다. Hive 언어 매뉴얼에서 :

  2. from https://stackoverflow.com/questions/11589084/date-difference-less-than-15-minutes-in-hive by cc-by-sa and MIT license