You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by "HAJIHASHEMI, ZAHRA (AG/1000)" <za...@monsanto.com> on 2012/09/26 22:56:05 UTC

RE: concat string in pig

I have two strings that I want to concatenate. The first one holds a number and coming from this set of commands:

library = LOAD 'discovery_library' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:TISSUE' ,'-loadKey true') as (id:int, name:chararray);
grpd = group library all;
data = foreach grpd generate MAX(library.id) as id;

The second one is a root path.
root_path = '/user/zahra/Sequence/data/';

I want to concatenate these two and create new path. For example if data=268, I would like to have : '/user/zhaji/Sequence/data/268'
When I used CONCAT(root_path, data), I got this error:

ERROR 1000: Error during parsing. Lexical error at line 15, column 14.  Encountered: "/" (47), after : "\""
Which is pointing to path assignment to roo_path variable!

Thanks for any help.

-Zahra

This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.

All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware".
Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
this e-mail or any attachment.


The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
Treasury, Office of Foreign Asset Controls (OFAC).  As a recipient of this information you are obligated to comply with all
applicable U.S. export laws and regulations.

Re: concat string in pig

Posted by Russell Jurney <ru...@gmail.com>.
I see what you're doing. You can't, so far as I know, store to a
scalar variable containing the path to store to. You could try using a
command line parameter?

Russell Jurney http://datasyndrome.com

On Sep 26, 2012, at 3:48 PM, "HAJIHASHEMI, ZAHRA (AG/1000)"
<za...@monsanto.com> wrote:

> Thanks Russell for your help.
> Here is my code and same error again!
> library = LOAD 'discovery_rnaseq_library' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:TISSUE' ,'-loadKey true') as (id:int, name:chararray);
> grpd = group library all;
> data = foreach grpd generate MAX(library.id) as id;
> path = CONCAT((chararray)id, '/user/zahra/Sequence/data/');
>
> (I also tried CONCAT((chararray)data) and CONCAT((chararray)data.id but got the same error)
>
> Here is error :
> 2012-09-26 17:43:52,796 [main] INFO  org.apache.pig.Main - Logging error messages to: /home/ZHAJI/pig_1348699432795.log
> 2012-09-26 17:43:52,939 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://stluhdpnpst01.monsanto.com:8020
> 2012-09-26 17:43:53,087 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to map-reduce job tracker at: stluhdpnpst01.monsanto.com:8021
> 2012-09-26 17:43:53,301 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Encountered " "(" "( "" at line 16, column 14.
> Was expecting one of:
>    "as" ...
>    ";" ...
>
>
> I appreciate your help.
>
>
> -----Original Message-----
> From: Russell Jurney [mailto:russell.jurney@gmail.com]
> Sent: Wednesday, September 26, 2012 4:50 PM
> To: user@pig.apache.org
> Subject: Re: concat string in pig
>
> CONCAT((chararray)id, '/user/zahra/Sequence/data/')
>
> Russell Jurney
> twitter.com/rjurney
> russell.jurney@gmail.com
> datasyndrome.com
>
> On Sep 26, 2012, at 1:56 PM, "HAJIHASHEMI, ZAHRA (AG/1000)"
> <za...@monsanto.com> wrote:
>
>> I have two strings that I want to concatenate. The first one holds a number and coming from this set of commands:
>>
>> library = LOAD 'discovery_library' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:TISSUE' ,'-loadKey true') as (id:int, name:chararray);
>> grpd = group library all;
>> data = foreach grpd generate MAX(library.id) as id;
>>
>> The second one is a root path.
>> root_path = '/user/zahra/Sequence/data/';
>>
>> I want to concatenate these two and create new path. For example if data=268, I would like to have : '/user/zhaji/Sequence/data/268'
>> When I used CONCAT(root_path, data), I got this error:
>>
>> ERROR 1000: Error during parsing. Lexical error at line 15, column 14.  Encountered: "/" (47), after : "\""
>> Which is pointing to path assignment to roo_path variable!
>>
>> Thanks for any help.
>>
>> -Zahra
>>
>> This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
>> to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
>> all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
>>
>> All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
>> subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware".
>> Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
>> this e-mail or any attachment.
>>
>>
>> The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
>> including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
>> Treasury, Office of Foreign Asset Controls (OFAC).  As a recipient of this information you are obligated to comply with all
>> applicable U.S. export laws and regulations.

RE: concat string in pig

Posted by "HAJIHASHEMI, ZAHRA (AG/1000)" <za...@monsanto.com>.
Thanks Russell for your help.
Here is my code and same error again!
library = LOAD 'discovery_rnaseq_library' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:TISSUE' ,'-loadKey true') as (id:int, name:chararray);
grpd = group library all;
data = foreach grpd generate MAX(library.id) as id;
path = CONCAT((chararray)id, '/user/zahra/Sequence/data/');

(I also tried CONCAT((chararray)data) and CONCAT((chararray)data.id but got the same error)

Here is error :
2012-09-26 17:43:52,796 [main] INFO  org.apache.pig.Main - Logging error messages to: /home/ZHAJI/pig_1348699432795.log
2012-09-26 17:43:52,939 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://stluhdpnpst01.monsanto.com:8020
2012-09-26 17:43:53,087 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to map-reduce job tracker at: stluhdpnpst01.monsanto.com:8021
2012-09-26 17:43:53,301 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Encountered " "(" "( "" at line 16, column 14.
Was expecting one of:
    "as" ...
    ";" ...


I appreciate your help.


-----Original Message-----
From: Russell Jurney [mailto:russell.jurney@gmail.com] 
Sent: Wednesday, September 26, 2012 4:50 PM
To: user@pig.apache.org
Subject: Re: concat string in pig

CONCAT((chararray)id, '/user/zahra/Sequence/data/')

Russell Jurney
twitter.com/rjurney
russell.jurney@gmail.com
datasyndrome.com

On Sep 26, 2012, at 1:56 PM, "HAJIHASHEMI, ZAHRA (AG/1000)"
<za...@monsanto.com> wrote:

> I have two strings that I want to concatenate. The first one holds a number and coming from this set of commands:
>
> library = LOAD 'discovery_library' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:TISSUE' ,'-loadKey true') as (id:int, name:chararray);
> grpd = group library all;
> data = foreach grpd generate MAX(library.id) as id;
>
> The second one is a root path.
> root_path = '/user/zahra/Sequence/data/';
>
> I want to concatenate these two and create new path. For example if data=268, I would like to have : '/user/zhaji/Sequence/data/268'
> When I used CONCAT(root_path, data), I got this error:
>
> ERROR 1000: Error during parsing. Lexical error at line 15, column 14.  Encountered: "/" (47), after : "\""
> Which is pointing to path assignment to roo_path variable!
>
> Thanks for any help.
>
> -Zahra
>
> This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
> to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
> all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
>
> All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
> subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware".
> Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
> this e-mail or any attachment.
>
>
> The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
> including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
> Treasury, Office of Foreign Asset Controls (OFAC).  As a recipient of this information you are obligated to comply with all
> applicable U.S. export laws and regulations.

Re: concat string in pig

Posted by Russell Jurney <ru...@gmail.com>.
CONCAT((chararray)id, '/user/zahra/Sequence/data/')

Russell Jurney
twitter.com/rjurney
russell.jurney@gmail.com
datasyndrome.com

On Sep 26, 2012, at 1:56 PM, "HAJIHASHEMI, ZAHRA (AG/1000)"
<za...@monsanto.com> wrote:

> I have two strings that I want to concatenate. The first one holds a number and coming from this set of commands:
>
> library = LOAD 'discovery_library' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:TISSUE' ,'-loadKey true') as (id:int, name:chararray);
> grpd = group library all;
> data = foreach grpd generate MAX(library.id) as id;
>
> The second one is a root path.
> root_path = '/user/zahra/Sequence/data/';
>
> I want to concatenate these two and create new path. For example if data=268, I would like to have : '/user/zhaji/Sequence/data/268'
> When I used CONCAT(root_path, data), I got this error:
>
> ERROR 1000: Error during parsing. Lexical error at line 15, column 14.  Encountered: "/" (47), after : "\""
> Which is pointing to path assignment to roo_path variable!
>
> Thanks for any help.
>
> -Zahra
>
> This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
> to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
> all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
>
> All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
> subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware".
> Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
> this e-mail or any attachment.
>
>
> The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
> including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
> Treasury, Office of Foreign Asset Controls (OFAC).  As a recipient of this information you are obligated to comply with all
> applicable U.S. export laws and regulations.