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

------------------------------------------------------------------------------
  .....
  }}}
  
+ In this example, the value of the `date` is expected to be passed on each 
invocation of the script and is substituted before running the pig script. An 
error is generated if the value for any parameter is not found.
- In this example, the value of the `date` parameter is expected to be passed 
on each invocation of the script and is substituted in before running the pig 
script. An error  
- is generated if the value for any parameter is not found.
  
- A parameter name have a structure of a standard language identifier: it must 
start with a latter or underscore followed by any number of letters, digits, 
and underscores. The  
+ A parameter name have a structure of a standard language identifier: it must 
start with a letter or underscore followed by any number of letters, digits, 
and underscores. The names are case insensitive. The names can be escaped with 
`\` in which case substitution does not take place.
- names are case insensitive. The names can be escaped with `\` in which case 
substitution does not take place.
  
  In the initial version of the software the parameters are only allowed when 
pig script is specified. They are disabled with `-e` switch or in the 
interactive mode. 
  
@@ -43, +41 @@

  
  ==== Command Line ====
  
- Parameters can be passed via pig command line using `-param <param>=<val>` 
construct. Multiple parameters can be specified. If the same parameter is 
specified multiple  
+ Parameters can be passed via pig command line using `-param <param>=<val>` 
construct. Multiple parameters can be specified. If the same parameter is 
specified multiple times, the last value will be used and a warning will be 
generated.
- times, the last value will be used and a warning will be generated.
- 
- The command line for Example 4 above would look as follows:
  
  {{{
  pig -param date='20080201'
@@ -54, +49 @@

  
  ==== Parameter File ====
  
+ Parameters can also be specified in a file that can be passed to pig using 
`-param_file <file>` construct. Multiple files can be specified. If the same 
parameter is present multiple times in the file, the last value will be used 
and a warning will be generated. If a parameter present in multiple files, the 
value from the last file will be used and a warning will be generated.
- Parameters can also be specified in a file that can be passed to pig using 
`-param_file <file>` construct. Multiple files can be specified. If the same 
parameter is present  
- multiple times in the file, the last value will be used and a warning will be 
generated. If a parameter present in multiple files, the value from the last 
file will be used  
- and a warning will be generated.
  
+ A parameter file will contain one line per parameter. Empty lines are 
allowed. Perl style (#) comment lines are also allowed. Comments must take a 
full line and `#` must be the first character on the line. Each parameter line 
will be of the form: `<param_name>=<param_value>`. White spaces around `=` are 
allowed but are optional. 
- A parameter file will contain one line per parameter. Empty lines are 
allowed. Perl style (#) comment lines are also allowed. Comments must take a 
full line and `#` must be  
- the first character on the line. Each parameter line will be of the form: 
`<param_name>=<param_value>`. White spaces around `=` are allowed but are 
optional. 
  
  {{{
  # my parameters
@@ -68, +60 @@

  cmd = `generate_name`
  }}}
  
- Files and command line parameters can be combined, with command line 
parameters taking precedence over files in case of duplicate parameters.
+ Files and command line parameters can be combined with command line 
parameters taking precedence.
  
  ==== Declare Statement ====
  
@@ -83, +75 @@

  
  The format is `%declare <param> <value>`
  
+ `declare` command starts with `%` to indicate that this is a preprocessor 
command that is processed prior to executing pig script. It takes the highest 
precedence. The scope of parameter value defined via `declare` is all the lines 
following `declare` command until the next `declare` command that defines the 
same parameter is encountered.
- `declare` command starts with `%` to indicate that this is a preprocessor 
command that is processed prior to executing pig script. It takes the highest 
precedence. The  
- scope of parameter value defined via `declare` is all the lines following 
`declare` command until the next `declare` command that defines this parameter 
is encountered.
  
  ==== Default Statement ====
  
- `default` command can be used to provide a default value for a parameter. 
This value is used if the parameter has no value defined by any other means. 
(`default` has the  
+ `default` command can be used to provide a default value for a parameter. 
This value is used if the parameter has no value defined by any other means. 
(`default` has the lowest priority.).
- lowest priority.).
  
  `default` has the format and scoping rules identical do `declare`.
  
@@ -99, +89 @@

  
  ==== Processing Order ====
  
-  1. Configuration files will be scanned in the order they are specified on 
the command line. Within each file, the parameters are processed in the order 
they are  
+  1. Configuration files are scanned in the order they are specified on the 
command line. Within each file, the parameters are processed in the order they 
are specified.
- specified.
-  2. Command line parameters will be scanned in the order they are specified 
on the command line.
+  2. Command line parameters are scanned in the order they are specified on 
the command line.
-  3. declare/default commands will be processed in the order they appear in 
the pig script.
+  3. declare/default statements are processed in the order they appear in the 
pig script.
  
  ==== Value Format ====
  
- Value format are identical regardless of how the parameter is specified and 
can be of two types. First is a sequence of characters enclosed in single or 
double quotes. In  
+ Value formats are identical regardless of how the parameter is specified and 
can be of two types. First is a sequence of characters enclosed in single or 
double quotes. In this case the unquoted version of the value is used during 
substitution. Quotes within the value can be escaped.
- this case the unquoted version of the value is used during substitution. 
Quotes within the value can be escaped.
  
  {{{
  %declare DESC 'Joe\'s URL'
@@ -128, +116 @@

  
  The values of both types can be expressed in terms of other parameters as 
long a the values of the dependent parameters are defined prior to this value.
  
- 
  {{{
  %declare CMD `$mycmd $date`
  A = load '/data/mydata/$CMD';
@@ -138, +125 @@

  
  In this example, parameters `mycmd` and `date` are substituted first when 
`declare` statement is encountered. Then the resulting command is executed and 
its stdout is  
  placed into the path prior to running the load statement.
- 
  
  === Debugging ===
  

Reply via email to