Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Pig Wiki" for change 
notification.

The following page has been changed by OlgaN:
http://wiki.apache.org/pig/ParameterSubstitution

------------------------------------------------------------------------------
  == Requirements ==
  
   1. Ability to have parameters within a pig script and provide values for 
this parameters at run time.
-  2. Ability to provide parameter values on the command file
+  2. Ability to provide parameter values on the command line
   3. Ability to provide parameter values in a file
-  4. Ability to generate parameter value at run time by running a binary or 
script.
+  4. Ability to generate parameter values at run time by running a binary or a 
script.
   5. Ability to provide default values for parameters
   6. Ability to retain the script with all parameters resolved. This is mostly 
for debugging purposes.
  
@@ -19, +19 @@

  
  === Parameter Specification ===
  
- Parameters in pig script will be of the for `$<identifier>`. 
+ Parameters in a pig script will be of the form `$<identifier>`. 
  
  {{{
- A = load '/data/mydata/%$date%';
+ A = load '/data/mydata/$date';
  B = filter A by $0>'5';
  .....
  }}}
  
- In this case, pig would expect the program to pass a value for parameter 
named `date` and will place it in the path before executing the load statement.
+ For this example, pig would expect `date` to be passed from pig command line 
or from a parameter file. The value would be substituted prior to running the 
load statement.
  
- In addition to parameters, a user can supply a command to execute to get the 
substitution value. This can be done using `declare` command.
+ In addition to supplying parameter value, a user can supply a command to 
execute to generate a parameter value. This can be done using `declare` 
statement.
  
  {{{
  declare CMD `generate_date`
@@ -38, +38 @@

  .....
  }}}
  
- In this case, pig would execute the program called `generate_date` when it 
encounters `declare` statement and place its stdout into the path before 
executing the load statement.
+ For this example, pig would execute `generate_date` command when it 
encounters the `declare` statement and assigns the result (stdout) to parameter 
`CMD`. The value of `CMD` is substituted prior to running the load statement.
  
  A command can take parameters which need to be substituted as well.
  
@@ -49, +49 @@

  .....
  }}}
  
- In this case, parameter `date` is substituted first, then `generate_name` 
command ran passing value of `date` as command line parameter and the stdout of 
the command is placed into the path prior to executing the load statement.
+ For this example, parameter `date` is substituted first when `declare` 
statement is encountered. Then `generate_name` command is executed passing 
value of `date` as a parameter to it. Its output (stdout) is assigned to `CMD` 
which is used in the load statement prior to its execution.
  
- Note that the variables passed on the command line must be resolved prior to 
the declare statement. This is wrong:
+ Note that the variables passed on the command line must be resolved prior to 
the declare statement. The following sequence would cause an error:
  
  {{{
  declare A `cmd1 $B`
@@ -67, +67 @@

  .....
  }}}
  
- In this case, parameters `cmd` and `date` are substituted first. The the 
resulting command is executed and its stdout is placed into the path prior to 
running the load statement.
+ In this example, parameters `cmd` and `date` are substituted first when 
`declare` statement is encountered. The the resulting command is executed and 
its stdout is placed into the path prior to running the load statement.
  
  Note that parameter names are case insesitive and $cmd and $CMD means the 
same thing. This is to match the rest of Pig Latin.
  

Reply via email to