的时间差小于15蜂巢分钟(Date Difference less than 15 minutes

2019-09-19 23:20发布

下面是我的查询,其中在最后一行,我想看看日期之间的差异在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

有什么毛病我查询? 或蜂房,我们无法计算在几分钟日期之间的差异? 任何建议将不胜感激。

Answer 1:

我认为这个问题是与你的加入。 从蜂房语言手册 :

只有平等连接,外连接,并留下半联接在蜂巢的支持。 蜂房不支持加入不在平等条件,因为它是非常困难的,表达了这样的条件作为地图/减少工作条件。



文章来源: Date Difference less than 15 minutes in Hive