user131990
user131990

Reputation: 85

JOIN condition in PIG Latin

SQL

SELECT m.x,m.y,n.a,n.b
from mydata1 m,mydata2 n
WHERE m.x=n.a
AND  m.y>= n.y

PIG

A = LOAD 'mydata1' AS (x: int, y: datetime);
B = LOAD 'mydata2' AS (a: int, b: datetime);  

I now need to join both the tables using the above sql condition. How will I implement the above logic in PIG using the join condition?

Upvotes: 1

Views: 307

Answers (1)

Murali Rao
Murali Rao

Reputation: 2287

Try this :

A = LOAD 'mydata1' AS (x: int, y: datetime);  
B = LOAD 'mydata2' AS (a: int, b: datetime); 
C = JOIN A BY x, B BY a;
D = FILTER C BY ToUnixTime(y) >= ToUnixTime(b);
DUMP D;

Upvotes: 2

Related Questions