You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Will Ford <wi...@alpinedatalabs.com> on 2013/04/05 02:08:47 UTC

CONCAT an open brace to a chararray (Pig v. 0.10)

Hi,

I am trying to concatenate an open brace ( "{" ) to a string and I believe pig thinks that I am trying to open a bag or something.

This does work:
A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray, c:chararray, d:chararray,e:chararray, f:chararray);
B = FOREACH A GENERATE CONCAT("\[",a);

This does not work:
A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray, c:chararray, d:chararray,e:chararray, f:chararray);
B = FOREACH A GENERATE CONCAT("\{",a);

It also does not work if I replace the second line with
B = FOREACH A GENERATE CONCAT("{",a);
-or-
B = FOREACH A GENERATE CONCAT("\\{",a);

Is there a way to add an open brace to field?

Thanks in advance for your help.

-Will

Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Will Ford <wi...@alpinedatalabs.com>.
So concat is not working with the conditions that have been outlined so
far but the following works.

B = STREAM A THROUGH `sed s/^/{/` as  (a:chararray, b:chararray,
c:chararray, d:chararray,e:chararray, f:chararray);

Thanks for the help.  I will submit a bug report.

-W


On 4/4/13 6:50 PM, "Russell Jurney" <ru...@gmail.com> wrote:

>Escaping the { in single quotes should work.
>
>Russell Jurney http://datasyndrome.com
>
>On Apr 4, 2013, at 6:23 PM, Ramakrishna Nalam <nr...@gmail.com>
>wrote:
>
>> Looks like you're having issues as '{' is a reserved character. Try
>>giving
>> the UTF-8 representation for it:
>>
>> '\\u007B'
>>
>>
>> Regards,
>> Rama.
>>
>>
>>
>> On Fri, Apr 5, 2013 at 6:04 AM, Will Ford
>><wi...@alpinedatalabs.com>wrote:
>>
>>> This is what I am seeing:
>>> grunt> B = FOREACH A GENERATE CONCAT('{',a);
>>>>> };
>>> 2013-04-04 17:31:27,132 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>>> ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
>>> Details at logfile: /Users/XXX/pig_1365116672592.log
>>> grunt> B = FOREACH A GENERATE CONCAT('\{',a);
>>>>> };
>>> <line 3, column 32>  Unexpected character '{'
>>> 2013-04-04 17:31:33,033 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>>> ERROR 1200: <line 3, column 32>  Unexpected character '{'
>>> Details at logfile: /Users/XXX/pig_1365116672592.log
>>> grunt> B = FOREACH A GENERATE CONCAT('\\{',a);
>>>>> };
>>> 2013-04-04 17:31:40,094 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>>> ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
>>> Details at logfile: /Users/XXX/pig_1365116672592.log
>>>
>>>
>>>
>>> I have to type }; to get back to the prompt.
>>>
>>> Thanks again for your help!
>>>
>>> -W
>>>
>>> On 4/4/13 5:27 PM, "Prashant Kommireddi" <pr...@gmail.com> wrote:
>>>
>>>> Pressed send too soon. Try this (single quotes)
>>>>
>>>> B = FOREACH A GENERATE CONCAT('{', a);
>>>>
>>>>
>>>> On Thu, Apr 4, 2013 at 5:26 PM, Prashant Kommireddi
>>>> <pr...@gmail.com>wrote:
>>>>
>>>>> Can you try single quotes?
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Apr 4, 2013 at 5:08 PM, Will Ford
>>>>> <wi...@alpinedatalabs.com>wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to concatenate an open brace ( "{" ) to a string and I
>>>>>> believe pig thinks that I am trying to open a bag or something.
>>>>>>
>>>>>> This does work:
>>>>>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray,
>>>>>>b:chararray,
>>>>>> c:chararray, d:chararray,e:chararray, f:chararray);
>>>>>> B = FOREACH A GENERATE CONCAT("\[",a);
>>>>>>
>>>>>> This does not work:
>>>>>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray,
>>>>>>b:chararray,
>>>>>> c:chararray, d:chararray,e:chararray, f:chararray);
>>>>>> B = FOREACH A GENERATE CONCAT("\{",a);
>>>>>>
>>>>>> It also does not work if I replace the second line with
>>>>>> B = FOREACH A GENERATE CONCAT("{",a);
>>>>>> -or-
>>>>>> B = FOREACH A GENERATE CONCAT("\\{",a);
>>>>>>
>>>>>> Is there a way to add an open brace to field?
>>>>>>
>>>>>> Thanks in advance for your help.
>>>>>>
>>>>>> -Will
>>>
>>>


Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Russell Jurney <ru...@gmail.com>.
Escaping the { in single quotes should work.

Russell Jurney http://datasyndrome.com

On Apr 4, 2013, at 6:23 PM, Ramakrishna Nalam <nr...@gmail.com> wrote:

> Looks like you're having issues as '{' is a reserved character. Try giving
> the UTF-8 representation for it:
>
> '\\u007B'
>
>
> Regards,
> Rama.
>
>
>
> On Fri, Apr 5, 2013 at 6:04 AM, Will Ford <wi...@alpinedatalabs.com>wrote:
>
>> This is what I am seeing:
>> grunt> B = FOREACH A GENERATE CONCAT('{',a);
>>>> };
>> 2013-04-04 17:31:27,132 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>> ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
>> Details at logfile: /Users/XXX/pig_1365116672592.log
>> grunt> B = FOREACH A GENERATE CONCAT('\{',a);
>>>> };
>> <line 3, column 32>  Unexpected character '{'
>> 2013-04-04 17:31:33,033 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>> ERROR 1200: <line 3, column 32>  Unexpected character '{'
>> Details at logfile: /Users/XXX/pig_1365116672592.log
>> grunt> B = FOREACH A GENERATE CONCAT('\\{',a);
>>>> };
>> 2013-04-04 17:31:40,094 [main] ERROR org.apache.pig.tools.grunt.Grunt -
>> ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
>> Details at logfile: /Users/XXX/pig_1365116672592.log
>>
>>
>>
>> I have to type }; to get back to the prompt.
>>
>> Thanks again for your help!
>>
>> -W
>>
>> On 4/4/13 5:27 PM, "Prashant Kommireddi" <pr...@gmail.com> wrote:
>>
>>> Pressed send too soon. Try this (single quotes)
>>>
>>> B = FOREACH A GENERATE CONCAT('{', a);
>>>
>>>
>>> On Thu, Apr 4, 2013 at 5:26 PM, Prashant Kommireddi
>>> <pr...@gmail.com>wrote:
>>>
>>>> Can you try single quotes?
>>>>
>>>>
>>>>
>>>> On Thu, Apr 4, 2013 at 5:08 PM, Will Ford
>>>> <wi...@alpinedatalabs.com>wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to concatenate an open brace ( "{" ) to a string and I
>>>>> believe pig thinks that I am trying to open a bag or something.
>>>>>
>>>>> This does work:
>>>>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>>>>> c:chararray, d:chararray,e:chararray, f:chararray);
>>>>> B = FOREACH A GENERATE CONCAT("\[",a);
>>>>>
>>>>> This does not work:
>>>>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>>>>> c:chararray, d:chararray,e:chararray, f:chararray);
>>>>> B = FOREACH A GENERATE CONCAT("\{",a);
>>>>>
>>>>> It also does not work if I replace the second line with
>>>>> B = FOREACH A GENERATE CONCAT("{",a);
>>>>> -or-
>>>>> B = FOREACH A GENERATE CONCAT("\\{",a);
>>>>>
>>>>> Is there a way to add an open brace to field?
>>>>>
>>>>> Thanks in advance for your help.
>>>>>
>>>>> -Will
>>
>>

Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Ramakrishna Nalam <nr...@gmail.com>.
Looks like you're having issues as '{' is a reserved character. Try giving
the UTF-8 representation for it:

'\\u007B'


Regards,
Rama.



On Fri, Apr 5, 2013 at 6:04 AM, Will Ford <wi...@alpinedatalabs.com>wrote:

> This is what I am seeing:
> grunt> B = FOREACH A GENERATE CONCAT('{',a);
> >> };
> 2013-04-04 17:31:27,132 [main] ERROR org.apache.pig.tools.grunt.Grunt -
> ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
> Details at logfile: /Users/XXX/pig_1365116672592.log
> grunt> B = FOREACH A GENERATE CONCAT('\{',a);
> >> };
> <line 3, column 32>  Unexpected character '{'
> 2013-04-04 17:31:33,033 [main] ERROR org.apache.pig.tools.grunt.Grunt -
> ERROR 1200: <line 3, column 32>  Unexpected character '{'
> Details at logfile: /Users/XXX/pig_1365116672592.log
> grunt> B = FOREACH A GENERATE CONCAT('\\{',a);
> >> };
> 2013-04-04 17:31:40,094 [main] ERROR org.apache.pig.tools.grunt.Grunt -
> ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
> Details at logfile: /Users/XXX/pig_1365116672592.log
>
>
>
> I have to type }; to get back to the prompt.
>
> Thanks again for your help!
>
> -W
>
> On 4/4/13 5:27 PM, "Prashant Kommireddi" <pr...@gmail.com> wrote:
>
> >Pressed send too soon. Try this (single quotes)
> >
> >B = FOREACH A GENERATE CONCAT('{', a);
> >
> >
> >On Thu, Apr 4, 2013 at 5:26 PM, Prashant Kommireddi
> ><pr...@gmail.com>wrote:
> >
> >> Can you try single quotes?
> >>
> >>
> >>
> >> On Thu, Apr 4, 2013 at 5:08 PM, Will Ford
> >><wi...@alpinedatalabs.com>wrote:
> >>
> >>> Hi,
> >>>
> >>> I am trying to concatenate an open brace ( "{" ) to a string and I
> >>> believe pig thinks that I am trying to open a bag or something.
> >>>
> >>> This does work:
> >>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
> >>> c:chararray, d:chararray,e:chararray, f:chararray);
> >>> B = FOREACH A GENERATE CONCAT("\[",a);
> >>>
> >>> This does not work:
> >>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
> >>> c:chararray, d:chararray,e:chararray, f:chararray);
> >>> B = FOREACH A GENERATE CONCAT("\{",a);
> >>>
> >>> It also does not work if I replace the second line with
> >>> B = FOREACH A GENERATE CONCAT("{",a);
> >>> -or-
> >>> B = FOREACH A GENERATE CONCAT("\\{",a);
> >>>
> >>> Is there a way to add an open brace to field?
> >>>
> >>> Thanks in advance for your help.
> >>>
> >>> -Will
> >>>
> >>
> >>
>
>

Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Will Ford <wi...@alpinedatalabs.com>.
This is what I am seeing:
grunt> B = FOREACH A GENERATE CONCAT('{',a);
>> };
2013-04-04 17:31:27,132 [main] ERROR org.apache.pig.tools.grunt.Grunt -
ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
Details at logfile: /Users/XXX/pig_1365116672592.log
grunt> B = FOREACH A GENERATE CONCAT('\{',a);
>> };
<line 3, column 32>  Unexpected character '{'
2013-04-04 17:31:33,033 [main] ERROR org.apache.pig.tools.grunt.Grunt -
ERROR 1200: <line 3, column 32>  Unexpected character '{'
Details at logfile: /Users/XXX/pig_1365116672592.log
grunt> B = FOREACH A GENERATE CONCAT('\\{',a);
>> };
2013-04-04 17:31:40,094 [main] ERROR org.apache.pig.tools.grunt.Grunt -
ERROR 1200: <line 4, column 0>  mismatched input '}' expecting EOF
Details at logfile: /Users/XXX/pig_1365116672592.log



I have to type }; to get back to the prompt.

Thanks again for your help!

-W

On 4/4/13 5:27 PM, "Prashant Kommireddi" <pr...@gmail.com> wrote:

>Pressed send too soon. Try this (single quotes)
>
>B = FOREACH A GENERATE CONCAT('{', a);
>
>
>On Thu, Apr 4, 2013 at 5:26 PM, Prashant Kommireddi
><pr...@gmail.com>wrote:
>
>> Can you try single quotes?
>>
>>
>>
>> On Thu, Apr 4, 2013 at 5:08 PM, Will Ford
>><wi...@alpinedatalabs.com>wrote:
>>
>>> Hi,
>>>
>>> I am trying to concatenate an open brace ( "{" ) to a string and I
>>> believe pig thinks that I am trying to open a bag or something.
>>>
>>> This does work:
>>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>>> c:chararray, d:chararray,e:chararray, f:chararray);
>>> B = FOREACH A GENERATE CONCAT("\[",a);
>>>
>>> This does not work:
>>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>>> c:chararray, d:chararray,e:chararray, f:chararray);
>>> B = FOREACH A GENERATE CONCAT("\{",a);
>>>
>>> It also does not work if I replace the second line with
>>> B = FOREACH A GENERATE CONCAT("{",a);
>>> -or-
>>> B = FOREACH A GENERATE CONCAT("\\{",a);
>>>
>>> Is there a way to add an open brace to field?
>>>
>>> Thanks in advance for your help.
>>>
>>> -Will
>>>
>>
>>


Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Prashant Kommireddi <pr...@gmail.com>.
Pressed send too soon. Try this (single quotes)

B = FOREACH A GENERATE CONCAT('{', a);


On Thu, Apr 4, 2013 at 5:26 PM, Prashant Kommireddi <pr...@gmail.com>wrote:

> Can you try single quotes?
>
>
>
> On Thu, Apr 4, 2013 at 5:08 PM, Will Ford <wi...@alpinedatalabs.com>wrote:
>
>> Hi,
>>
>> I am trying to concatenate an open brace ( "{" ) to a string and I
>> believe pig thinks that I am trying to open a bag or something.
>>
>> This does work:
>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>> c:chararray, d:chararray,e:chararray, f:chararray);
>> B = FOREACH A GENERATE CONCAT("\[",a);
>>
>> This does not work:
>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>> c:chararray, d:chararray,e:chararray, f:chararray);
>> B = FOREACH A GENERATE CONCAT("\{",a);
>>
>> It also does not work if I replace the second line with
>> B = FOREACH A GENERATE CONCAT("{",a);
>> -or-
>> B = FOREACH A GENERATE CONCAT("\\{",a);
>>
>> Is there a way to add an open brace to field?
>>
>> Thanks in advance for your help.
>>
>> -Will
>>
>
>

Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Will Ford <wi...@alpinedatalabs.com>.
Single quotes yields the same behavior.

-W

On 4/4/13 5:26 PM, "Prashant Kommireddi" <pr...@gmail.com> wrote:

>Can you try single quotes?
>
>
>
>On Thu, Apr 4, 2013 at 5:08 PM, Will Ford
><wi...@alpinedatalabs.com>wrote:
>
>> Hi,
>>
>> I am trying to concatenate an open brace ( "{" ) to a string and I
>>believe
>> pig thinks that I am trying to open a bag or something.
>>
>> This does work:
>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>> c:chararray, d:chararray,e:chararray, f:chararray);
>> B = FOREACH A GENERATE CONCAT("\[",a);
>>
>> This does not work:
>> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
>> c:chararray, d:chararray,e:chararray, f:chararray);
>> B = FOREACH A GENERATE CONCAT("\{",a);
>>
>> It also does not work if I replace the second line with
>> B = FOREACH A GENERATE CONCAT("{",a);
>> -or-
>> B = FOREACH A GENERATE CONCAT("\\{",a);
>>
>> Is there a way to add an open brace to field?
>>
>> Thanks in advance for your help.
>>
>> -Will
>>


Re: CONCAT an open brace to a chararray (Pig v. 0.10)

Posted by Prashant Kommireddi <pr...@gmail.com>.
Can you try single quotes?



On Thu, Apr 4, 2013 at 5:08 PM, Will Ford <wi...@alpinedatalabs.com>wrote:

> Hi,
>
> I am trying to concatenate an open brace ( "{" ) to a string and I believe
> pig thinks that I am trying to open a bag or something.
>
> This does work:
> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
> c:chararray, d:chararray,e:chararray, f:chararray);
> B = FOREACH A GENERATE CONCAT("\[",a);
>
> This does not work:
> A = LOAD 'short' USING PigStorage('\t') AS (a:chararray, b:chararray,
> c:chararray, d:chararray,e:chararray, f:chararray);
> B = FOREACH A GENERATE CONCAT("\{",a);
>
> It also does not work if I replace the second line with
> B = FOREACH A GENERATE CONCAT("{",a);
> -or-
> B = FOREACH A GENERATE CONCAT("\\{",a);
>
> Is there a way to add an open brace to field?
>
> Thanks in advance for your help.
>
> -Will
>