新猪用户。我将 mysql 语句转换为 pig 并遇到了以下问题。我有 2 个需要加入的表,并且加入的值有一个计算。我认为这一定是一个简单的问题。
例如,我的表是machine1和machinemeansPig
,我加入了它们。在手册中找不到用于在加入中进行计算的语法。有什么建议么?
select region, os, group, f.machine, f.machine_users, f.machine_tm,
f.machine_users - g.users_per_machine outliers,
f.machine_tm - g.tm_per_machine outlying_tm,
tm_per_machine/(f.machine_tm+1) factor
from machine1 f
inner join machinemeans g using(region, os, group)
order by 4, 1, 2, 3
谢谢
更新:谢谢,温妮尼克劳斯。我试过你的建议,但我得到一个标量有超过 1 行的输出错误。这是我的代码。
machine1 = LOAD 'S1' AS (
block:chararray,
region:chararray,
os:chararray,
group:int,
machine:int,
machine_users:int,
machine_tm:float
);
machinemeans = LOAD 'S2' AS (
region:chararray,
os:chararray,
group:int,
tot_machines:int,
tot_users:int,
users_per_machine:float,
tm_per_machine:float,
tm_per_user:float,
cnt_per_block:float,
cnt_per_user:float
);
imbalance = FOREACH (JOIN machine1 by (region,os,group),
machine2 by (region,os,group))
GENERATE
region,os,group,
machine1.machine,
machine1.machine_users,
machine1.machine_tm,
machine1.machine_users - machinemeans.users_per_machine,
machine1.machine_tm - machinemeans.tm_per_machine;