Hello,
I am also getting this error. But with Integer not Number.
Caused by: java.lang.ClassCastException: org.apache.pig.data.DataByteArray
cannot be cast to java.lang.Integer
at org.apache.pig.builtin.IntAvg$Initial.exec(IntAvg.java:87)
Here is my code.
1 njWeather = LOAD '/data/njWeather.csv' USING PigStorage(',');
2 timeTemp = FOREACH njWeather GENERATE $5 AS ts:chararray, $38 AS temp:int;
3 timeTempt2 = FOREACH timeTemp GENERATE ToDate(ts, 'yyyyMMdd HH:mm') AS
ts:DateTime , temp AS temp:int;
4 tempAtMidnight = FILTER timeTempt2 BY GetHour(ts)==0;
5 Y = GROUP tempAtMidnight ALL;
6 Z = FOREACH Y GENERATE AVG(tempAtMidnight.temp);
7 STORE Y INTO '/data/Y.csv';
8 DUMP Z;
Storing Y works fine. I have verified that every temp value in Y.csv is an
integer. But the DUMP Z throws that aforementioned exception.
I've also done the following for good measure.
9 justTemptAtMidnight = FOREACH tempAtMidnight GENERATE temp AS temp:int;
10 X = FOREACH (GROUP justTemptAtMidnight ALL) GENERATE
AVG(justTemptAtMidnight.temp
11 STORE justTemptAtMidnight INTO '/data/justTemptAtMidnight .csv';
12 DUMP X;
But same result. I have also verified that every line in justTemptAtMidnight
.csv is "^[0-9]+$"
Any ideas?
thanks
j