Hive: work around for non equi left join

前端 未结 4 1724
耶瑟儿~
耶瑟儿~ 2020-12-18 09:57

Hive does not support non equi joins: The common work around is to move the join condition to the where clause, which work fine when you want an inner join. but what about a

4条回答
  •  借酒劲吻你
    2020-12-18 10:42

    Why not use a WHERE clause that allows for NULL cases separately?

    SELECT * FROM OrderLineItem li 
    LEFT OUTER JOIN  ProductPrice p 
    ON p.ProductID=li.ProductID 
    WHERE ( StartDate IS NULL OR OrderDate BETWEEN startDate AND EndDate);
    

    That should take care of it - if the left join matches it'll use the date logic, if it doesn't it'll keep the NULL values intact as a left join should.

提交回复
热议问题