user3900607
user3900607

Reputation: 93

Pig Script without load

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.

Upvotes: 9

Views: 812

Answers (2)

Bryan Linton
Bryan Linton

Reputation: 456

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!

Upvotes: 3

merours
merours

Reputation: 4106

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.

Upvotes: 1

Related Questions