[Solved-2 Solutions] Pig Script without load ?



What is Pig Script ?

  • Pig is a high level scripting language that is used with Apache Hadoop.
  • Pig enables data workers to write complex data transformations without knowing Java.
  • Pig's simple SQL-like scripting language is called Pig Latin, and appeals to developers already familiar with scripting languages and SQL.

Problem:

  • If you trying to figure out how to define a bag or tuple with hard coded values, without loading data from a file.
  • Every example that have encountered with starts with:
a = LOAD '/file/name' using PigStorage(',');

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

Solution 1:

  • There is no way to declare hard coded values with PigLatin itself. If wish to test your scripts, we may want to use UDF. This will declare what we want in the language of your choice.

Solution 2:

  • Unfortunately it is impossible to just create a tuple or bag in Pig like this in the current version (0.15.0).
  • It is suggested 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,

Related Searches to Pig Script without load