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中,我们不能用分钟来计算日期之间的差异?如有任何建议,我们将不胜感激。

我认为问题出在您的联接上。来自Hive语言手册:

中仅支持相等联接、外部联接和左半联接蜂箱配置单元不支持不相等的联接条件条件,因为很难将这些条件表示为映射/减少作业。

相关内容

  • 没有找到相关文章

最新更新