|
|
Hi,
I'm trying to load the following records using PigStorage(',') as (val:int, m:map[ ])... When I see dump of output I only get first column and empty value..
151364,[id#812,pref#secondary]
121211,[id#212,pref#primary]
Could some one suggest me how to load above records..
Thanks, Srinivas
-
Re: Loading Map's in Pig
pablomar 2012-08-30, 17:09
I guess it is because you are using ',' as separator (there is a comma between your val and the map) and then again inside the map (is that a bug ?)
I tried with a space to separate the int from the map (input.txt): 151364 [id#812,pref#secondary] 121211 [id#212,pref#primary]
and with this script: data = load 'input.txt' using PigStorage(' ') as (val:int, m:Map[]); dump data;
I got: (151364,[id#812,pref#secondary]) (121211,[id#212,pref#primary])
On Thu, Aug 30, 2012 at 9:49 AM, Srini <[EMAIL PROTECTED]> wrote:
> Hi, > > I'm trying to load the following records using PigStorage(',') as > (val:int, m:map[ ])... When I see dump of output I only get first column > and empty value.. > > 151364,[id#812,pref#secondary] > > 121211,[id#212,pref#primary] > > Could some one suggest me how to load above records.. > > Thanks, > Srinivas >
-
Re: Loading Map's in Pig
Cheolsoo Park 2012-08-30, 17:43
Looking at PigStorage source code, this looks like what's happening.
When the comma ',' is the delimiter, PigStorage splits the input string as follows:
151364,[id#812,pref#secondary]
=>
151364 [id#812 pref#secondary]
Now "[id#812" is not a map literal, so it ends up being null.
Thanks, Cheolsoo
On Thu, Aug 30, 2012 at 10:09 AM, pablomar <[EMAIL PROTECTED]>wrote:
> I guess it is because you are using ',' as separator (there is a comma > between your val and the map) and then again inside the map (is that a bug > ?) > > I tried with a space to separate the int from the map (input.txt): > 151364 [id#812,pref#secondary] > 121211 [id#212,pref#primary] > > and with this script: > data = load 'input.txt' using PigStorage(' ') as (val:int, m:Map[]); > dump data; > > I got: > (151364,[id#812,pref#secondary]) > (121211,[id#212,pref#primary]) > > > > On Thu, Aug 30, 2012 at 9:49 AM, Srini <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I'm trying to load the following records using PigStorage(',') as > > (val:int, m:map[ ])... When I see dump of output I only get first column > > and empty value.. > > > > 151364,[id#812,pref#secondary] > > > > 121211,[id#212,pref#primary] > > > > Could some one suggest me how to load above records.. > > > > Thanks, > > Srinivas > > >
-
Re: Loading Map's in Pig
pablomar 2012-08-30, 17:45
good finding ! On Thu, Aug 30, 2012 at 1:43 PM, Cheolsoo Park <[EMAIL PROTECTED]>wrote:
> Looking at PigStorage source code, this looks like what's happening. > > When the comma ',' is the delimiter, PigStorage splits the input string as > follows: > > 151364,[id#812,pref#secondary] > > => > > 151364 > [id#812 > pref#secondary] > > Now "[id#812" is not a map literal, so it ends up being null. > > Thanks, > Cheolsoo > > On Thu, Aug 30, 2012 at 10:09 AM, pablomar > <[EMAIL PROTECTED]>wrote: > > > I guess it is because you are using ',' as separator (there is a comma > > between your val and the map) and then again inside the map (is that a > bug > > ?) > > > > I tried with a space to separate the int from the map (input.txt): > > 151364 [id#812,pref#secondary] > > 121211 [id#212,pref#primary] > > > > and with this script: > > data = load 'input.txt' using PigStorage(' ') as (val:int, m:Map[]); > > dump data; > > > > I got: > > (151364,[id#812,pref#secondary]) > > (121211,[id#212,pref#primary]) > > > > > > > > On Thu, Aug 30, 2012 at 9:49 AM, Srini <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > > I'm trying to load the following records using PigStorage(',') as > > > (val:int, m:map[ ])... When I see dump of output I only get first > column > > > and empty value.. > > > > > > 151364,[id#812,pref#secondary] > > > > > > 121211,[id#212,pref#primary] > > > > > > Could some one suggest me how to load above records.. > > > > > > Thanks, > > > Srinivas > > > > > >
-
Re: Loading Map's in Pig
Srini 2012-08-31, 13:06
Thanks Pablo and Cheolsoo ..
On Thu, Aug 30, 2012 at 1:45 PM, pablomar <[EMAIL PROTECTED]>wrote:
> good finding ! > > > On Thu, Aug 30, 2012 at 1:43 PM, Cheolsoo Park <[EMAIL PROTECTED] > >wrote: > > > Looking at PigStorage source code, this looks like what's happening. > > > > When the comma ',' is the delimiter, PigStorage splits the input string > as > > follows: > > > > 151364,[id#812,pref#secondary] > > > > => > > > > 151364 > > [id#812 > > pref#secondary] > > > > Now "[id#812" is not a map literal, so it ends up being null. > > > > Thanks, > > Cheolsoo > > > > On Thu, Aug 30, 2012 at 10:09 AM, pablomar > > <[EMAIL PROTECTED]>wrote: > > > > > I guess it is because you are using ',' as separator (there is a comma > > > between your val and the map) and then again inside the map (is that a > > bug > > > ?) > > > > > > I tried with a space to separate the int from the map (input.txt): > > > 151364 [id#812,pref#secondary] > > > 121211 [id#212,pref#primary] > > > > > > and with this script: > > > data = load 'input.txt' using PigStorage(' ') as (val:int, m:Map[]); > > > dump data; > > > > > > I got: > > > (151364,[id#812,pref#secondary]) > > > (121211,[id#212,pref#primary]) > > > > > > > > > > > > On Thu, Aug 30, 2012 at 9:49 AM, Srini <[EMAIL PROTECTED]> wrote: > > > > > > > Hi, > > > > > > > > I'm trying to load the following records using PigStorage(',') as > > > > (val:int, m:map[ ])... When I see dump of output I only get first > > column > > > > and empty value.. > > > > > > > > 151364,[id#812,pref#secondary] > > > > > > > > 121211,[id#212,pref#primary] > > > > > > > > Could some one suggest me how to load above records.. > > > > > > > > Thanks, > > > > Srinivas > > > > > > > > > >
-- Regards, Srinivas [EMAIL PROTECTED]
|
|