1

I have the following data:

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

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

my Pig Latin script is:

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 ;

the error message :

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long

any help please

Mohd Zoubi
  • 186
  • 3
  • 16

2 Answers2

0

The problem you have is that you are mixing an int data type with a long data type.

You need to manually convert the int to long.

Tim
  • 834
  • 2
  • 12
  • 31
0

The problem is that COUNT return a long but you convert it to int Your code should look like this:

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

or

BB= foreach BA generate group as EDU, COUNT (Data_filter1) as cn:long;
Mzf
  • 5,210
  • 2
  • 24
  • 37