hadoop - how to use bincode operator in group function in pig -
i need group below data on fname , lastname.
(fname,lname,id)
abc,xyz,i abc,xyz,n ppp,xxx,i ppp,xxx,i
in id field expecting 2 values i.e n or if both n , same fname,lname combination should use id n else need use value id field given in group.
i expecting below results:
abc,xyz,n ppp,xxx,i
i have tried below code , working fine
in =load '/testing/name.txt' using pigstorage(',') (fname:chararray,lname:chararray,id:chararray); grp = group in (fname,lname); z = foreach grp generate flatten(group) (fname,lname),(count(in.id) >1 ? ('n') :bagtotuple(in.id))as id;
however need check values of id field instead of counts:
z = foreach grp generate flatten(group) (fname,lname),((in.id == 'n' or in.id == 'i') ? ('n') :bagtotuple(in.id))as id;
however giving below error:
(name: equal type: null uid: null)incompatible types in equal operator left hand side:bag :tuple(id:chararray) right hand side:chararray
however giving below error:
two inputs of bincond must have compatible schemas. left hand side: #31:tuple(#32:chararray) right hand side: org.apache.pig.builtin.bagtotuple_3#35:tuple(id#36:int)
please guide
you loading field contains chars i.e. n,i int column? change load statement id column type chararray.
in =load '/testing/name.txt' using pigstorage(',') (fname:chararray,lname:chararray,id:chararray); grp = group in (fname,lname); z = foreach grp generate flatten(group) (fname,lname),(count(in.id) > 1 && in.id matches 'n') ? ('n') : in.id;
Comments
Post a Comment