You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by yo...@wipro.com on 2012/07/25 20:06:02 UTC

foreach in PIG is not working.

Hi all,

I loaded a file to pig by command from HDFS.

A=load '/HADOOP/Yogesh/demo.txt'
as (name:chararray, roll:int);

its get loaded and when i do

dump A:

it shows

(Yogesh 12,)
(Aashi 13,)
(mohit 14,)

Now i run another query

B= foreach A generate name;

to get result only names from A.

but dump B; hows the same result as of    dump A; i.e

(Yogesh 12,)
(Aashi 13,)
(mohit 14,)


Please help and suggest.

Thanks & Regards
Yogesh Kumar

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

Re: foreach in PIG is not working.

Posted by Mohammad Tariq <do...@gmail.com>.
Hi Yogesh,

          As per the result of dump A, it is correct. Just see that
whatever is there in A, it's one complete chararray (Yogesh 12,).
Although you are trying to load the file as (name:chararray,
roll:int), it is going as a single field ans not (name:chararray,
roll:int). Just try to load the file properly, and you are good to go.

Regards,
    Mohammad Tariq


On Wed, Jul 25, 2012 at 11:36 PM,  <yo...@wipro.com> wrote:
> Hi all,
>
> I loaded a file to pig by command from HDFS.
>
> A=load '/HADOOP/Yogesh/demo.txt'
> as (name:chararray, roll:int);
>
> its get loaded and when i do
>
> dump A:
>
> it shows
>
> (Yogesh 12,)
> (Aashi 13,)
> (mohit 14,)
>
> Now i run another query
>
> B= foreach A generate name;
>
> to get result only names from A.
>
> but dump B; hows the same result as of    dump A; i.e
>
> (Yogesh 12,)
> (Aashi 13,)
> (mohit 14,)
>
>
> Please help and suggest.
>
> Thanks & Regards
> Yogesh Kumar
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> www.wipro.com

RE: foreach in PIG is not working.

Posted by Ruslan Al-fakikh <ru...@jalent.ru>.
Hi,

It seems that you are having problems with separators. Even you first dump
shows columns where the first one contains everything and the second one is
empty

Ruslan

-----Original Message-----
From: yogesh.kumar13@wipro.com [mailto:yogesh.kumar13@wipro.com] 
Sent: Wednesday, July 25, 2012 10:06 PM
To: user@pig.apache.org
Subject: foreach in PIG is not working.
Importance: High

Hi all,

I loaded a file to pig by command from HDFS.

A=load '/HADOOP/Yogesh/demo.txt'
as (name:chararray, roll:int);

its get loaded and when i do

dump A:

it shows

(Yogesh 12,)
(Aashi 13,)
(mohit 14,)

Now i run another query

B= foreach A generate name;

to get result only names from A.

but dump B; hows the same result as of    dump A; i.e

(Yogesh 12,)
(Aashi 13,)
(mohit 14,)


Please help and suggest.

Thanks & Regards
Yogesh Kumar

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain proprietary, confidential or privileged information. If you are not
the intended recipient, you should not disseminate, distribute or copy this
e-mail. Please notify the sender immediately and destroy all copies of this
message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The
company accepts no liability for any damage caused by any virus transmitted
by this email. 

www.wipro.com


Re: foreach in PIG is not working.

Posted by John Meagher <jo...@gmail.com>.
Change:  using PigStorage(',')
to:  using PigStorage(' ')
The delimiter passed into PigStorage does not appear to be correct.

On Wed, Jul 25, 2012 at 2:31 PM,  <yo...@wipro.com> wrote:
> Thanks All :-)
>
> yes the file I have uploaded was text file having format
> (Yogesh 12)
> (Aashi 13)
> (Mohit 14)
>
>
> I used command
>
>  A = load '/Yogesh/demo.txt' using PigStorage(',')
>>> as (name:chararray, roll:int);
>
> and then Dump A;
>
> The result is
>
> (Yogesh 12,)
> (Aashi 13,)
> (Mohit 14,)
>
> it should be
>
> (Yogesh, 12)
> (Aashi , 13)
> (Mohit, 14)
>
> Whats I am missing here :-( ?
>
> Regards
> Yogesh Kumar
>
> ________________________________________
> From: Mohammad Tariq [dontariq@gmail.com]
> Sent: Wednesday, July 25, 2012 11:50 PM
> To: user@pig.apache.org
> Subject: Re: foreach in PIG is not working.
>
> try this :
> A=load '/HADOOP/Yogesh/demo.txt' using PigStorage (' ') as
> (name:chararray, roll:int)
>
> Regards,
>     Mohammad Tariq
>
>
> On Wed, Jul 25, 2012 at 11:47 PM, pablomar
> <pa...@gmail.com> wrote:
>> are the commas in your file in the write places ?
>> your DUMP A shows
>> (Yogesh 12,)
>> (Aashi 13,)
>> (mohit 14,)
>>
>> comma after the number. It makes me believe that it is taking both fields
>> as name, so when you do the foreach, it keeps the whole thing
>>
>> I mean, is your file (wrong)
>> Yogesh 12,
>> Aashi 13,
>> mohit 14,
>>
>> or (good, for this case)
>> Yogesh, 12
>> Aashi, 13
>> mohit, 14
>>
>>
>> On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:
>>
>>> Hi all,
>>>
>>> I loaded a file to pig by command from HDFS.
>>>
>>> A=load '/HADOOP/Yogesh/demo.txt'
>>> as (name:chararray, roll:int);
>>>
>>> its get loaded and when i do
>>>
>>> dump A:
>>>
>>> it shows
>>>
>>> (Yogesh 12,)
>>> (Aashi 13,)
>>> (mohit 14,)
>>>
>>> Now i run another query
>>>
>>> B= foreach A generate name;
>>>
>>> to get result only names from A.
>>>
>>> but dump B; hows the same result as of    dump A; i.e
>>>
>>> (Yogesh 12,)
>>> (Aashi 13,)
>>> (mohit 14,)
>>>
>>>
>>> Please help and suggest.
>>>
>>> Thanks & Regards
>>> Yogesh Kumar
>>>
>>> Please do not print this email unless it is absolutely necessary.
>>>
>>> The information contained in this electronic message and any attachments
>>> to this message are intended for the exclusive use of the addressee(s) and
>>> may contain proprietary, confidential or privileged information. If you are
>>> not the intended recipient, you should not disseminate, distribute or copy
>>> this e-mail. Please notify the sender immediately and destroy all copies of
>>> this message and any attachments.
>>>
>>> WARNING: Computer viruses can be transmitted via email. The recipient
>>> should check this email and any attachments for the presence of viruses.
>>> The company accepts no liability for any damage caused by any virus
>>> transmitted by this email.
>>>
>>> www.wipro.com
>>>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> www.wipro.com

RE: foreach in PIG is not working.

Posted by yo...@wipro.com.
Thanks All :-)

Now it worked, Thanks Mohammad :-),

Thanks & Regards
Yogesh Kumar

________________________________________
From: Mohammad Tariq [dontariq@gmail.com]
Sent: Thursday, July 26, 2012 12:12 AM
To: user@pig.apache.org
Subject: Re: foreach in PIG is not working.

complete query would be something like this :

grunt> a = load '/dir1/demo.txt' using PigStorage (' ') as
(name:chararray, roll:int );     #Pay special attention to "PigStorage
(' ')"..Don't use


                                         comma there
grunt> dump a;

grunt> b = foreach a generate name;

grunt> dump b;

Regards,
    Mohammad Tariq


On Thu, Jul 26, 2012 at 12:06 AM, Mohammad Tariq <do...@gmail.com> wrote:
> Don't use (',')...By default, LOAD looks for our data in a
> tab-delimited file using the default LOAD function i.e PigStorage. But
> the data in your file is "space separated" and not tab-separated. So
> you need to tell Pig in what manner  you want to load your file. See
> the command properly which I have shown in the previous mail.
> A=load '/HADOOP/Yogesh/demo.txt' using PigStorage ('  ') as
> (name:chararray, roll:int)
>
> Pay attention to "PigStorage ('  ')"..I haven't used comma there. Use
> it..It should work.
>
> Regards,
>     Mohammad Tariq
>
>
> On Thu, Jul 26, 2012 at 12:01 AM,  <yo...@wipro.com> wrote:
>> Thanks All :-)
>>
>> yes the file I have uploaded was text file having format
>> (Yogesh 12)
>> (Aashi 13)
>> (Mohit 14)
>>
>>
>> I used command
>>
>>  A = load '/Yogesh/demo.txt' using PigStorage(',')
>>>> as (name:chararray, roll:int);
>>
>> and then Dump A;
>>
>> The result is
>>
>> (Yogesh 12,)
>> (Aashi 13,)
>> (Mohit 14,)
>>
>> it should be
>>
>> (Yogesh, 12)
>> (Aashi , 13)
>> (Mohit, 14)
>>
>> Whats I am missing here :-( ?
>>
>> Regards
>> Yogesh Kumar
>>
>> ________________________________________
>> From: Mohammad Tariq [dontariq@gmail.com]
>> Sent: Wednesday, July 25, 2012 11:50 PM
>> To: user@pig.apache.org
>> Subject: Re: foreach in PIG is not working.
>>
>> try this :
>> A=load '/HADOOP/Yogesh/demo.txt' using PigStorage (' ') as
>> (name:chararray, roll:int)
>>
>> Regards,
>>     Mohammad Tariq
>>
>>
>> On Wed, Jul 25, 2012 at 11:47 PM, pablomar
>> <pa...@gmail.com> wrote:
>>> are the commas in your file in the write places ?
>>> your DUMP A shows
>>> (Yogesh 12,)
>>> (Aashi 13,)
>>> (mohit 14,)
>>>
>>> comma after the number. It makes me believe that it is taking both fields
>>> as name, so when you do the foreach, it keeps the whole thing
>>>
>>> I mean, is your file (wrong)
>>> Yogesh 12,
>>> Aashi 13,
>>> mohit 14,
>>>
>>> or (good, for this case)
>>> Yogesh, 12
>>> Aashi, 13
>>> mohit, 14
>>>
>>>
>>> On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I loaded a file to pig by command from HDFS.
>>>>
>>>> A=load '/HADOOP/Yogesh/demo.txt'
>>>> as (name:chararray, roll:int);
>>>>
>>>> its get loaded and when i do
>>>>
>>>> dump A:
>>>>
>>>> it shows
>>>>
>>>> (Yogesh 12,)
>>>> (Aashi 13,)
>>>> (mohit 14,)
>>>>
>>>> Now i run another query
>>>>
>>>> B= foreach A generate name;
>>>>
>>>> to get result only names from A.
>>>>
>>>> but dump B; hows the same result as of    dump A; i.e
>>>>
>>>> (Yogesh 12,)
>>>> (Aashi 13,)
>>>> (mohit 14,)
>>>>
>>>>
>>>> Please help and suggest.
>>>>
>>>> Thanks & Regards
>>>> Yogesh Kumar
>>>>
>>>> Please do not print this email unless it is absolutely necessary.
>>>>
>>>> The information contained in this electronic message and any attachments
>>>> to this message are intended for the exclusive use of the addressee(s) and
>>>> may contain proprietary, confidential or privileged information. If you are
>>>> not the intended recipient, you should not disseminate, distribute or copy
>>>> this e-mail. Please notify the sender immediately and destroy all copies of
>>>> this message and any attachments.
>>>>
>>>> WARNING: Computer viruses can be transmitted via email. The recipient
>>>> should check this email and any attachments for the presence of viruses.
>>>> The company accepts no liability for any damage caused by any virus
>>>> transmitted by this email.
>>>>
>>>> www.wipro.com
>>>>
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>>
>> www.wipro.com

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

Re: foreach in PIG is not working.

Posted by Mohammad Tariq <do...@gmail.com>.
complete query would be something like this :

grunt> a = load '/dir1/demo.txt' using PigStorage (' ') as
(name:chararray, roll:int );     #Pay special attention to "PigStorage
(' ')"..Don't use


                                         comma there
grunt> dump a;

grunt> b = foreach a generate name;

grunt> dump b;

Regards,
    Mohammad Tariq


On Thu, Jul 26, 2012 at 12:06 AM, Mohammad Tariq <do...@gmail.com> wrote:
> Don't use (',')...By default, LOAD looks for our data in a
> tab-delimited file using the default LOAD function i.e PigStorage. But
> the data in your file is "space separated" and not tab-separated. So
> you need to tell Pig in what manner  you want to load your file. See
> the command properly which I have shown in the previous mail.
> A=load '/HADOOP/Yogesh/demo.txt' using PigStorage ('  ') as
> (name:chararray, roll:int)
>
> Pay attention to "PigStorage ('  ')"..I haven't used comma there. Use
> it..It should work.
>
> Regards,
>     Mohammad Tariq
>
>
> On Thu, Jul 26, 2012 at 12:01 AM,  <yo...@wipro.com> wrote:
>> Thanks All :-)
>>
>> yes the file I have uploaded was text file having format
>> (Yogesh 12)
>> (Aashi 13)
>> (Mohit 14)
>>
>>
>> I used command
>>
>>  A = load '/Yogesh/demo.txt' using PigStorage(',')
>>>> as (name:chararray, roll:int);
>>
>> and then Dump A;
>>
>> The result is
>>
>> (Yogesh 12,)
>> (Aashi 13,)
>> (Mohit 14,)
>>
>> it should be
>>
>> (Yogesh, 12)
>> (Aashi , 13)
>> (Mohit, 14)
>>
>> Whats I am missing here :-( ?
>>
>> Regards
>> Yogesh Kumar
>>
>> ________________________________________
>> From: Mohammad Tariq [dontariq@gmail.com]
>> Sent: Wednesday, July 25, 2012 11:50 PM
>> To: user@pig.apache.org
>> Subject: Re: foreach in PIG is not working.
>>
>> try this :
>> A=load '/HADOOP/Yogesh/demo.txt' using PigStorage (' ') as
>> (name:chararray, roll:int)
>>
>> Regards,
>>     Mohammad Tariq
>>
>>
>> On Wed, Jul 25, 2012 at 11:47 PM, pablomar
>> <pa...@gmail.com> wrote:
>>> are the commas in your file in the write places ?
>>> your DUMP A shows
>>> (Yogesh 12,)
>>> (Aashi 13,)
>>> (mohit 14,)
>>>
>>> comma after the number. It makes me believe that it is taking both fields
>>> as name, so when you do the foreach, it keeps the whole thing
>>>
>>> I mean, is your file (wrong)
>>> Yogesh 12,
>>> Aashi 13,
>>> mohit 14,
>>>
>>> or (good, for this case)
>>> Yogesh, 12
>>> Aashi, 13
>>> mohit, 14
>>>
>>>
>>> On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I loaded a file to pig by command from HDFS.
>>>>
>>>> A=load '/HADOOP/Yogesh/demo.txt'
>>>> as (name:chararray, roll:int);
>>>>
>>>> its get loaded and when i do
>>>>
>>>> dump A:
>>>>
>>>> it shows
>>>>
>>>> (Yogesh 12,)
>>>> (Aashi 13,)
>>>> (mohit 14,)
>>>>
>>>> Now i run another query
>>>>
>>>> B= foreach A generate name;
>>>>
>>>> to get result only names from A.
>>>>
>>>> but dump B; hows the same result as of    dump A; i.e
>>>>
>>>> (Yogesh 12,)
>>>> (Aashi 13,)
>>>> (mohit 14,)
>>>>
>>>>
>>>> Please help and suggest.
>>>>
>>>> Thanks & Regards
>>>> Yogesh Kumar
>>>>
>>>> Please do not print this email unless it is absolutely necessary.
>>>>
>>>> The information contained in this electronic message and any attachments
>>>> to this message are intended for the exclusive use of the addressee(s) and
>>>> may contain proprietary, confidential or privileged information. If you are
>>>> not the intended recipient, you should not disseminate, distribute or copy
>>>> this e-mail. Please notify the sender immediately and destroy all copies of
>>>> this message and any attachments.
>>>>
>>>> WARNING: Computer viruses can be transmitted via email. The recipient
>>>> should check this email and any attachments for the presence of viruses.
>>>> The company accepts no liability for any damage caused by any virus
>>>> transmitted by this email.
>>>>
>>>> www.wipro.com
>>>>
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>>
>> www.wipro.com

Re: foreach in PIG is not working.

Posted by Mohammad Tariq <do...@gmail.com>.
Don't use (',')...By default, LOAD looks for our data in a
tab-delimited file using the default LOAD function i.e PigStorage. But
the data in your file is "space separated" and not tab-separated. So
you need to tell Pig in what manner  you want to load your file. See
the command properly which I have shown in the previous mail.
A=load '/HADOOP/Yogesh/demo.txt' using PigStorage ('  ') as
(name:chararray, roll:int)

Pay attention to "PigStorage ('  ')"..I haven't used comma there. Use
it..It should work.

Regards,
    Mohammad Tariq


On Thu, Jul 26, 2012 at 12:01 AM,  <yo...@wipro.com> wrote:
> Thanks All :-)
>
> yes the file I have uploaded was text file having format
> (Yogesh 12)
> (Aashi 13)
> (Mohit 14)
>
>
> I used command
>
>  A = load '/Yogesh/demo.txt' using PigStorage(',')
>>> as (name:chararray, roll:int);
>
> and then Dump A;
>
> The result is
>
> (Yogesh 12,)
> (Aashi 13,)
> (Mohit 14,)
>
> it should be
>
> (Yogesh, 12)
> (Aashi , 13)
> (Mohit, 14)
>
> Whats I am missing here :-( ?
>
> Regards
> Yogesh Kumar
>
> ________________________________________
> From: Mohammad Tariq [dontariq@gmail.com]
> Sent: Wednesday, July 25, 2012 11:50 PM
> To: user@pig.apache.org
> Subject: Re: foreach in PIG is not working.
>
> try this :
> A=load '/HADOOP/Yogesh/demo.txt' using PigStorage (' ') as
> (name:chararray, roll:int)
>
> Regards,
>     Mohammad Tariq
>
>
> On Wed, Jul 25, 2012 at 11:47 PM, pablomar
> <pa...@gmail.com> wrote:
>> are the commas in your file in the write places ?
>> your DUMP A shows
>> (Yogesh 12,)
>> (Aashi 13,)
>> (mohit 14,)
>>
>> comma after the number. It makes me believe that it is taking both fields
>> as name, so when you do the foreach, it keeps the whole thing
>>
>> I mean, is your file (wrong)
>> Yogesh 12,
>> Aashi 13,
>> mohit 14,
>>
>> or (good, for this case)
>> Yogesh, 12
>> Aashi, 13
>> mohit, 14
>>
>>
>> On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:
>>
>>> Hi all,
>>>
>>> I loaded a file to pig by command from HDFS.
>>>
>>> A=load '/HADOOP/Yogesh/demo.txt'
>>> as (name:chararray, roll:int);
>>>
>>> its get loaded and when i do
>>>
>>> dump A:
>>>
>>> it shows
>>>
>>> (Yogesh 12,)
>>> (Aashi 13,)
>>> (mohit 14,)
>>>
>>> Now i run another query
>>>
>>> B= foreach A generate name;
>>>
>>> to get result only names from A.
>>>
>>> but dump B; hows the same result as of    dump A; i.e
>>>
>>> (Yogesh 12,)
>>> (Aashi 13,)
>>> (mohit 14,)
>>>
>>>
>>> Please help and suggest.
>>>
>>> Thanks & Regards
>>> Yogesh Kumar
>>>
>>> Please do not print this email unless it is absolutely necessary.
>>>
>>> The information contained in this electronic message and any attachments
>>> to this message are intended for the exclusive use of the addressee(s) and
>>> may contain proprietary, confidential or privileged information. If you are
>>> not the intended recipient, you should not disseminate, distribute or copy
>>> this e-mail. Please notify the sender immediately and destroy all copies of
>>> this message and any attachments.
>>>
>>> WARNING: Computer viruses can be transmitted via email. The recipient
>>> should check this email and any attachments for the presence of viruses.
>>> The company accepts no liability for any damage caused by any virus
>>> transmitted by this email.
>>>
>>> www.wipro.com
>>>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> www.wipro.com

RE: foreach in PIG is not working.

Posted by yo...@wipro.com.
Thanks All :-)

yes the file I have uploaded was text file having format
(Yogesh 12)
(Aashi 13)
(Mohit 14)


I used command 

 A = load '/Yogesh/demo.txt' using PigStorage(',')
>> as (name:chararray, roll:int);

and then Dump A;

The result is 

(Yogesh 12,)
(Aashi 13,)
(Mohit 14,)

it should be 

(Yogesh, 12)
(Aashi , 13)
(Mohit, 14)

Whats I am missing here :-( ?

Regards
Yogesh Kumar

________________________________________
From: Mohammad Tariq [dontariq@gmail.com]
Sent: Wednesday, July 25, 2012 11:50 PM
To: user@pig.apache.org
Subject: Re: foreach in PIG is not working.

try this :
A=load '/HADOOP/Yogesh/demo.txt' using PigStorage (' ') as
(name:chararray, roll:int)

Regards,
    Mohammad Tariq


On Wed, Jul 25, 2012 at 11:47 PM, pablomar
<pa...@gmail.com> wrote:
> are the commas in your file in the write places ?
> your DUMP A shows
> (Yogesh 12,)
> (Aashi 13,)
> (mohit 14,)
>
> comma after the number. It makes me believe that it is taking both fields
> as name, so when you do the foreach, it keeps the whole thing
>
> I mean, is your file (wrong)
> Yogesh 12,
> Aashi 13,
> mohit 14,
>
> or (good, for this case)
> Yogesh, 12
> Aashi, 13
> mohit, 14
>
>
> On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:
>
>> Hi all,
>>
>> I loaded a file to pig by command from HDFS.
>>
>> A=load '/HADOOP/Yogesh/demo.txt'
>> as (name:chararray, roll:int);
>>
>> its get loaded and when i do
>>
>> dump A:
>>
>> it shows
>>
>> (Yogesh 12,)
>> (Aashi 13,)
>> (mohit 14,)
>>
>> Now i run another query
>>
>> B= foreach A generate name;
>>
>> to get result only names from A.
>>
>> but dump B; hows the same result as of    dump A; i.e
>>
>> (Yogesh 12,)
>> (Aashi 13,)
>> (mohit 14,)
>>
>>
>> Please help and suggest.
>>
>> Thanks & Regards
>> Yogesh Kumar
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any attachments
>> to this message are intended for the exclusive use of the addressee(s) and
>> may contain proprietary, confidential or privileged information. If you are
>> not the intended recipient, you should not disseminate, distribute or copy
>> this e-mail. Please notify the sender immediately and destroy all copies of
>> this message and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The recipient
>> should check this email and any attachments for the presence of viruses.
>> The company accepts no liability for any damage caused by any virus
>> transmitted by this email.
>>
>> www.wipro.com
>>

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

Re: foreach in PIG is not working.

Posted by Mohammad Tariq <do...@gmail.com>.
try this :
A=load '/HADOOP/Yogesh/demo.txt' using PigStorage (' ') as
(name:chararray, roll:int)

Regards,
    Mohammad Tariq


On Wed, Jul 25, 2012 at 11:47 PM, pablomar
<pa...@gmail.com> wrote:
> are the commas in your file in the write places ?
> your DUMP A shows
> (Yogesh 12,)
> (Aashi 13,)
> (mohit 14,)
>
> comma after the number. It makes me believe that it is taking both fields
> as name, so when you do the foreach, it keeps the whole thing
>
> I mean, is your file (wrong)
> Yogesh 12,
> Aashi 13,
> mohit 14,
>
> or (good, for this case)
> Yogesh, 12
> Aashi, 13
> mohit, 14
>
>
> On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:
>
>> Hi all,
>>
>> I loaded a file to pig by command from HDFS.
>>
>> A=load '/HADOOP/Yogesh/demo.txt'
>> as (name:chararray, roll:int);
>>
>> its get loaded and when i do
>>
>> dump A:
>>
>> it shows
>>
>> (Yogesh 12,)
>> (Aashi 13,)
>> (mohit 14,)
>>
>> Now i run another query
>>
>> B= foreach A generate name;
>>
>> to get result only names from A.
>>
>> but dump B; hows the same result as of    dump A; i.e
>>
>> (Yogesh 12,)
>> (Aashi 13,)
>> (mohit 14,)
>>
>>
>> Please help and suggest.
>>
>> Thanks & Regards
>> Yogesh Kumar
>>
>> Please do not print this email unless it is absolutely necessary.
>>
>> The information contained in this electronic message and any attachments
>> to this message are intended for the exclusive use of the addressee(s) and
>> may contain proprietary, confidential or privileged information. If you are
>> not the intended recipient, you should not disseminate, distribute or copy
>> this e-mail. Please notify the sender immediately and destroy all copies of
>> this message and any attachments.
>>
>> WARNING: Computer viruses can be transmitted via email. The recipient
>> should check this email and any attachments for the presence of viruses.
>> The company accepts no liability for any damage caused by any virus
>> transmitted by this email.
>>
>> www.wipro.com
>>

Re: foreach in PIG is not working.

Posted by pablomar <pa...@gmail.com>.
are the commas in your file in the write places ?
your DUMP A shows
(Yogesh 12,)
(Aashi 13,)
(mohit 14,)

comma after the number. It makes me believe that it is taking both fields
as name, so when you do the foreach, it keeps the whole thing

I mean, is your file (wrong)
Yogesh 12,
Aashi 13,
mohit 14,

or (good, for this case)
Yogesh, 12
Aashi, 13
mohit, 14


On Wed, Jul 25, 2012 at 2:06 PM, <yo...@wipro.com> wrote:

> Hi all,
>
> I loaded a file to pig by command from HDFS.
>
> A=load '/HADOOP/Yogesh/demo.txt'
> as (name:chararray, roll:int);
>
> its get loaded and when i do
>
> dump A:
>
> it shows
>
> (Yogesh 12,)
> (Aashi 13,)
> (mohit 14,)
>
> Now i run another query
>
> B= foreach A generate name;
>
> to get result only names from A.
>
> but dump B; hows the same result as of    dump A; i.e
>
> (Yogesh 12,)
> (Aashi 13,)
> (mohit 14,)
>
>
> Please help and suggest.
>
> Thanks & Regards
> Yogesh Kumar
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments
> to this message are intended for the exclusive use of the addressee(s) and
> may contain proprietary, confidential or privileged information. If you are
> not the intended recipient, you should not disseminate, distribute or copy
> this e-mail. Please notify the sender immediately and destroy all copies of
> this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email.
>
> www.wipro.com
>