Hadoop 如何计算整数和的乘法

Hadoop 如何计算整数和的乘法,hadoop,apache-pig,Hadoop,Apache Pig,我有一只猪是这样描述的: DESCRIBE B; B: {group: chararray, A: {name: chararray,age: int,gpa: float}} [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1039: <file test.pig, line xx, column xx> (Name: Multiply Type: null Uid: null)incompatible types in

我有一只猪是这样描述的:

DESCRIBE B;
B: {group: chararray, A: {name: chararray,age: int,gpa: float}}
[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1039: <file test.pig, line xx, column xx> (Name: Multiply Type: null Uid: null)incompatible types in Multiply Operator left hand side:bag :tuple(gpa:float)  right hand side:bag :tuple(gap:float)
我想计算
∑清管器中的B.A.gpa2

但如果我写:

FOREACH B {
    out = SUM(A.gpa * A.gpa);
}
它抛出了这样一种误解:

DESCRIBE B;
B: {group: chararray, A: {name: chararray,age: int,gpa: float}}
[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1039: <file test.pig, line xx, column xx> (Name: Multiply Type: null Uid: null)incompatible types in Multiply Operator left hand side:bag :tuple(gpa:float)  right hand side:bag :tuple(gap:float)

您的临时解决方案适用于PIG。请记住,PIG是一种简单的数据流语言,它可以为您提供开箱即用的95%的解决方案,剩下的5%可以通过UDF实现。要查看如何编写UDF的好例子,请查看。

您的临时解决方案对于PIG来说是正确的。请记住,PIG是一种简单的数据流语言,它可以为您提供开箱即用的95%的解决方案,剩下的5%可以通过UDF实现。要查看如何编写UDF的好例子,请查看