You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Austin Chungath <au...@gmail.com> on 2012/02/22 05:43:48 UTC

how to address a column name which has space in between its name? "New York"

Consider
describe A;
A: {New York: chararray, Delhi: chararray}

B = foreach a generate New York;

error:
mismatched input 'York' expecting SEMI_COLON

Is there an escape sequence for space in pig scripts?
I understand that it is not possible to create a column name with a space
in pig using scripts.
The column name with a space was created when my UDF created a schema
taking values from a tuple and that tuple had this string "New York".
Ideally I should have checked for spaces in the string and replaced it with
an underscore, but just out of curiosity is there a way to address a column
named "New York"?

Any help is much appreciated.
Thanks,

Austin

Re: how to address a column name which has space in between its name? "New York"

Posted by Austin Chungath <au...@gmail.com>.
Hi Jonathan,
I didn't get any error when the schema function returned a bad variable
name.
Thanks,
Austin
On Wed, Feb 22, 2012 at 2:03 PM, Jonathan Coveney <jc...@gmail.com>wrote:

> That said, if there are rules around alias names, then there should
> probably be an error thrown if a schema function outputs a bad variable
> name.
>
> 2012/2/21 Austin Chungath <au...@gmail.com>
>
> > Thanks Prashant.
> >
> > On Wed, Feb 22, 2012 at 10:37 AM, Prashant Kommireddi
> > <pr...@gmail.com>wrote:
> >
> > > Replacing space with underscore is a good option. Alias is like
> variable
> > > declaration in any language which are guided by certain rules and
> syntax.
> > > http://pig.apache.org/docs/r0.9.1/basic.html#Data+Types+and+More
> > >
> > > On Tue, Feb 21, 2012 at 8:43 PM, Austin Chungath <au...@gmail.com>
> > > wrote:
> > >
> > > > Consider
> > > > describe A;
> > > > A: {New York: chararray, Delhi: chararray}
> > > >
> > > > B = foreach a generate New York;
> > > >
> > > > error:
> > > > mismatched input 'York' expecting SEMI_COLON
> > > >
> > > > Is there an escape sequence for space in pig scripts?
> > > > I understand that it is not possible to create a column name with a
> > space
> > > > in pig using scripts.
> > > > The column name with a space was created when my UDF created a schema
> > > > taking values from a tuple and that tuple had this string "New York".
> > > > Ideally I should have checked for spaces in the string and replaced
> it
> > > with
> > > > an underscore, but just out of curiosity is there a way to address a
> > > column
> > > > named "New York"?
> > > >
> > > > Any help is much appreciated.
> > > > Thanks,
> > > >
> > > > Austin
> > > >
> > >
> >
>

Re: how to address a column name which has space in between its name? "New York"

Posted by Jonathan Coveney <jc...@gmail.com>.
That said, if there are rules around alias names, then there should
probably be an error thrown if a schema function outputs a bad variable
name.

2012/2/21 Austin Chungath <au...@gmail.com>

> Thanks Prashant.
>
> On Wed, Feb 22, 2012 at 10:37 AM, Prashant Kommireddi
> <pr...@gmail.com>wrote:
>
> > Replacing space with underscore is a good option. Alias is like variable
> > declaration in any language which are guided by certain rules and syntax.
> > http://pig.apache.org/docs/r0.9.1/basic.html#Data+Types+and+More
> >
> > On Tue, Feb 21, 2012 at 8:43 PM, Austin Chungath <au...@gmail.com>
> > wrote:
> >
> > > Consider
> > > describe A;
> > > A: {New York: chararray, Delhi: chararray}
> > >
> > > B = foreach a generate New York;
> > >
> > > error:
> > > mismatched input 'York' expecting SEMI_COLON
> > >
> > > Is there an escape sequence for space in pig scripts?
> > > I understand that it is not possible to create a column name with a
> space
> > > in pig using scripts.
> > > The column name with a space was created when my UDF created a schema
> > > taking values from a tuple and that tuple had this string "New York".
> > > Ideally I should have checked for spaces in the string and replaced it
> > with
> > > an underscore, but just out of curiosity is there a way to address a
> > column
> > > named "New York"?
> > >
> > > Any help is much appreciated.
> > > Thanks,
> > >
> > > Austin
> > >
> >
>

Re: how to address a column name which has space in between its name? "New York"

Posted by Austin Chungath <au...@gmail.com>.
Thanks Prashant.

On Wed, Feb 22, 2012 at 10:37 AM, Prashant Kommireddi
<pr...@gmail.com>wrote:

> Replacing space with underscore is a good option. Alias is like variable
> declaration in any language which are guided by certain rules and syntax.
> http://pig.apache.org/docs/r0.9.1/basic.html#Data+Types+and+More
>
> On Tue, Feb 21, 2012 at 8:43 PM, Austin Chungath <au...@gmail.com>
> wrote:
>
> > Consider
> > describe A;
> > A: {New York: chararray, Delhi: chararray}
> >
> > B = foreach a generate New York;
> >
> > error:
> > mismatched input 'York' expecting SEMI_COLON
> >
> > Is there an escape sequence for space in pig scripts?
> > I understand that it is not possible to create a column name with a space
> > in pig using scripts.
> > The column name with a space was created when my UDF created a schema
> > taking values from a tuple and that tuple had this string "New York".
> > Ideally I should have checked for spaces in the string and replaced it
> with
> > an underscore, but just out of curiosity is there a way to address a
> column
> > named "New York"?
> >
> > Any help is much appreciated.
> > Thanks,
> >
> > Austin
> >
>

Re: how to address a column name which has space in between its name? "New York"

Posted by Prashant Kommireddi <pr...@gmail.com>.
Replacing space with underscore is a good option. Alias is like variable
declaration in any language which are guided by certain rules and syntax.
http://pig.apache.org/docs/r0.9.1/basic.html#Data+Types+and+More

On Tue, Feb 21, 2012 at 8:43 PM, Austin Chungath <au...@gmail.com> wrote:

> Consider
> describe A;
> A: {New York: chararray, Delhi: chararray}
>
> B = foreach a generate New York;
>
> error:
> mismatched input 'York' expecting SEMI_COLON
>
> Is there an escape sequence for space in pig scripts?
> I understand that it is not possible to create a column name with a space
> in pig using scripts.
> The column name with a space was created when my UDF created a schema
> taking values from a tuple and that tuple had this string "New York".
> Ideally I should have checked for spaces in the string and replaced it with
> an underscore, but just out of curiosity is there a way to address a column
> named "New York"?
>
> Any help is much appreciated.
> Thanks,
>
> Austin
>