1

我有以下数据:

AGE,EDU,SEX,SALARY
67,10th,Male,<=50K
17,10th,Female,<=50K
40,Assoc-voc,Male,>50K
35,Assoc-voc,Male,<=50K
57,Assoc-voc,Male,<=50K
49,Assoc-voc,Male,>50K
42,Bachelors,Male,>50K
30,Bachelors,Male,>50K
23,Bachelors,Female,<=50K

==================================================== ======

我的猪拉丁文脚本是:

sensitive = LOAD '/mdsba' using PigStorage(',') as (AGE,EDU,SEX,SALARY);
--Filtered the data by the city
Data_filter1 = FILTER sensitive by (SALARY matches '<=50K');
Data_filter2 = FILTER sensitive by (SALARY matches '>50K');
BA= group  Data_filter1 by (EDU,SEX) ; 

BB= foreach BA generate group as EDU, COUNT (Data_filter1) as cn:int;

BC= FILTER BB by (cn == 4);

Dump BC ;

错误信息:

java.lang.ClassCastException:java.lang.Integer 无法转换为 java.lang.Long

请有任何帮助

4

2 回答 2

0

您遇到的问题是您将 int 数据类型与 long 数据类型混合在一起。

您需要手动将 int 转换为 long。

于 2016-03-26T05:56:05.770 回答
0

问题是COUNT返回 long 但您将其转换为 int 您的代码应如下所示:

BB= foreach BA generate group as EDU, COUNT (Data_filter1) as cn;

或者

BB= foreach BA generate group as EDU, COUNT (Data_filter1) as cn:long;
于 2016-03-28T17:45:29.843 回答