Apache pig 在pig中对多个键执行联接时出现语法错误

Apache pig 在pig中对多个键执行联接时出现语法错误,apache-pig,Apache Pig,正在尝试在pig中加入2个文件内容 StringFile = load 'String' using PigStorage(',') as (name,branch,div); -- string values NumFile = load 'num' using PigStorage(',') as (id,m1,m2,m3,m4); -- numeric values joined = join id by name,(m1,m2) by branch,div by (m3,m4); sto

正在尝试在pig中加入2个文件内容

StringFile = load 'String' using PigStorage(',') as (name,branch,div); -- string values
NumFile = load 'num' using PigStorage(',') as (id,m1,m2,m3,m4); -- numeric values
joined = join id by name,(m1,m2) by branch,div by (m3,m4);
store joined into 'joinedfile' using PigStorage(',');
但是展示

[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <file filterjoin.pig, line 4, column 14>  Syntax error, unexpected symbol at or near '('
我做错什么了吗

从课本

也可以在多个关键点上进行连接。在任何情况下,您都必须具有 相同数量的键,并且它们必须具有相同或兼容的类型 (如果兼容,则表示可以插入隐式转换。)


我想您误解了
join
的作用。它通过一个公共元素连接两个数据集。因此语法是:

C = join A by a1, B by b1;
其中a1和b1是它们各自关系的字段,它们也有注释元素

例如:

students = 
1 rob
2 john 
3 fred

gpas =  
1 3.2 
2 3.8 
3 4.0

A = join students by id, gpas by id;

A =  
1 rob 1 3.2 
2 john 2 3.8 
3 fred 3 4.0

+1谢谢robthewolf。这个字段应该在两个包中都是通用的,对吗?如果我需要像上面提到的那样加入呢?目前没有直接的方法。你正在尝试连接两条没有连接的线。当然,除非列表是有序的。对此,没有保证。你可能必须使用UDF,如果是这样的话。我建议仔细考虑你想做什么,以及我对join的解释,看看你是否能找到解决方法。我会创建第三个查找表,可以连接你已经拥有的2个。robthewolf如果我为这两个文件生成一个id并尝试加入,它可能会正常工作(包括UDF)?如果您有匹配的ID,我认为您也不需要UDF@robthewolf:元组中的顺序如何变化?行对行交换或列对列交换或两者兼而有之。
C = join A by a1, B by b1;
students = 
1 rob
2 john 
3 fred

gpas =  
1 3.2 
2 3.8 
3 4.0

A = join students by id, gpas by id;

A =  
1 rob 1 3.2 
2 john 2 3.8 
3 fred 3 4.0