Welcome to the Linux Foundation Forum!

Workaround for non-equi left join in the hive

Non-equi joins are not supported by Hive: The popular work around is to relocate the join condition to the where clause, which works great when you want an inner join. What about a left join, though?
One of these examples given here is supposed we have an orderLineItem table, and we need to link to a ProductPrice table that includes a productID, price & a date period for which the price applies. We'd want to connect this where ProductID=ProductID and OrderDate are between the start and end dates. I still want to display all orderLineItems if a productID or a suitable date range does not match.
If I implement the normal solution and shift the non-equi filter to the where clause, it becomes an inner join. In the examples above, SQL tinker, and below, I have a product ID that isn't in the lookup.
Given that hive does not accept non-equi-joins, How is a left non-equivalence achieved?
Tables:

  1. CREATE TABLE OrderLineItem(
  2. LineItemIDId int IDENTITY(1,1),
  3. OrderID int NOT NULL,
  4. ProductID int NOT NULL,
  5. OrderDate Date
  6. );
  7.  
  8.  
  9. CREATE TABLE ProductPrice(
  10. ProductID int,
  11. Cost float,
  12. startDate Date,
  13. EndDate Date
  14.  
  15.  
  16. );

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training