On 26 January 2016 at 15:59, Divya Gehlot <divya.htco...@gmail.com> wrote:

> Hi Prashant ,
> Thanks for your solution.
> But got stuck in one more issue .
> How do I pass this tuple to group by function
>
> I tried passing it
> getting below error
>
> grunt> Load_cfl = LOAD '/user/hdfs/pig/data/cfl.txt' USING PigStorage('|')
>> as
>> (cfl_code:chararray,book_code:int,currency_code:chararray,start_date:datetime,end_date:datetime,cfl_type:chararray,amount:double
>> );
>> grunt> grouped_data = group Load_cfl by (TUPLED);
>> 2016-01-26 02:56:48,871 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>> ERROR 1200: Pig script failed to parse:
>> <line 7, column 34> Invalid scalar projection: TUPLED : A column needs to
>> be projected from a relation for it to be used as a scalar
>> Details at logfile: /home/hdfs/pig_1453794921782.log
>
>
>
> Would really appreciate your help.
>
> Thanks,
> Divya
>
> On 26 January 2016 at 13:51, Prashant Kommireddi <prash1...@gmail.com>
> wrote:
>
>> Does this solve it?
>>
>> grunt> DATA = LOAD 'data' USING PigStorage('|') as (groupBy:chararray ,
>> condition :chararray);
>>
>> grunt> FILTERED = FILTER DATA BY condition == 'Y';
>>
>> grunt> GROUPED = GROUP FILTERED BY condition;
>>
>> grunt> TUPLED = foreach GROUPED generate
>> FLATTEN(BagToTuple(FILTERED.groupBy));
>>
>> grunt> describe TUPLED;
>>
>> TUPLED: {org.apache.pig.builtin.bagtotuple_482::groupBy: chararray}
>>
>> grunt> dump TUPLED;
>>
>> (Column1,Column3,Column4)
>>
>>
>>
>> On Mon, Jan 25, 2016 at 6:55 PM, Divya Gehlot <divya.htco...@gmail.com>
>> wrote:
>>
>> > Hi,
>> > I have file data as below
>> > Data is dynamic
>> >
>> > Column1 | Y
>> > Column2 | N
>> > Column3 |Y
>> > Column4| Y
>> > Column5|N
>> >
>> > I need to filter the data which is Y and then
>> > read those columns as tuple so that I can pass to my Groupby function
>> >
>> > Filter data
>> > Column1,Y
>> > Column3,Y
>> > Column4,Y
>> >
>> > and then cnvert column1,column3,column4 as tuple .
>> >
>> > Would really aprreciate the pointers.
>> >
>> > Thanks,
>> > Divya
>> >
>>
>
>

Reply via email to