Search code examples
hiveapache-pighiveql

Multiple JOIN in Pig Latin


In HQL, we have

JOIN weather ON (weather.Year = flight.Year AND weather.Month = flight.Month and weather.Day=flight.DayofMonth)

In Pig Latin, is it possible to fit it into one query? Or I have to do it separately and combine them?


Solution

  • Its possible see here :

    You can also join on multiple keys. In all cases you must have the same number of keys, and they must be of the same or compatible types

    Example :

    weather = load '/weather/files/' as (Year,Month,Day,Fieldx);
    flight = load '/flight/files/' as (Year,Month,Day,Fieldy);
    jnd   = join weather by (Year,Month,Day), flight by (Year,Month,Day);