Samuel Kerrien
Samuel Kerrien

Reputation: 7085

Cannot compute MAX

Setup data

mkdir data
echo -e "1\n2\n3\n4\n8\n4\n3\n6" > data/data.txt

Launch Pig in local mode

pig -x local

Script

a = load 'data' Using PigStorage() As (value:int);
b = foreach a generate MAX(value);
dump b;

ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1045: Could not infer the matching function for org.apache.pig.builtin.MAX as multiple or none of them fit. Please use an explicit cast.

Upvotes: 2

Views: 2659

Answers (1)

Samuel Kerrien
Samuel Kerrien

Reputation: 7085

Just found the answer, it just take a GROUP ALL before calling the function ... Kind of feel the error message could be a little clearer ...

a = load 'data' Using PigStorage() As (value:int);
b = GROUP a ALL;
c = foreach b generate MAX(a.value);
dump c;

> 8

Upvotes: 2

Related Questions