hadoop中的连接条件

8wigbo56  于 2021-05-30  发布在  Hadoop
关注(0)|答案(1)|浏览(344)

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);

我现在需要使用上面的sql条件连接这两个表。如何使用连接条件在pig中实现上述逻辑?

bnlyeluc

bnlyeluc1#

试试这个:

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;

相关问题