Pig Script without load
Asked Answered
S

2

9

I am a newbie to Pig. I am trying to figure out how to define a bag or tuple with hard coded values, without loading data from a file. Every example that I have encountered with starts with:

a = LOAD '/file/name' using PigStorage(',');

or something similar. I just want to create a tuple or bag like this:

a = <1,2,3>;

Is it possible to use hard coded values for testing purposes?

Thanks.

Sphincter answered 1/8, 2014 at 19:34 Comment(1)
Great question ! You might want to format edit it though, in order to format your code and to add the pig version you're using.Lalonde
G
3

Unfortunately it is impossible to just create a tuple or bag in Pig like this in the current version (0.15.0).

My suggestion is to create a simple text file with a few values separated by commas, and use the following command:

a = LOAD '/path' using PigStorage(',');

The text file should look something like:

1,2,3

Hopefully in future versions they will release some way to accomplish creating a tuple or bag with a single command.

Good Luck practicing Pig!

Gelhar answered 11/2, 2016 at 22:15 Comment(0)
L
1

As far as I can tell, there is no way to declare hard coded values with PigLatin itself. If you wish to test your scripts, you may want to use UDF. This will let you declare what you want in the language of your choice.

Lalonde answered 6/8, 2014 at 16:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.