Added by Matt Casters, last edited by Bruno Medeiros on Apr 10, 2012  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Introduction

Named parameters are a system that allows you to parameterize your transformations and jobs.  On top of the variables system that was already in place prior to the introduction in version 3.2, named parameters offer the setting of a description and a default value.  That allows you in turn to list the required parameters for a job or transformation.

How it works

You can go to the settings dialog of your transformation or job and there you will find the "Parameters" tab...


 
Once these parameters are set they are used at runtime.  If a value is set, that is used.  If no value is set for a parameter, the default is used.

Passing values

Spoon development

The execution dialog of transformations and jobs allow you to set a value for each named parameter that is defined...

At the command line

In both Pan and Kitchen you can list the defined parameters:

user@host:$ sh pan.sh -file:/tmp/foo.ktr -listparam
Parameter: MASTER_HOST=, default=localhost : The master slave server hostname to connect to
Parameter: MASTER_PORT=, default=8080 : The master slave server HTTP control port

You can also define parameters during execution like this:

user@host:$ sh pan.sh -file:/tmp/foo.ktr -param:MASTER_HOST=192.168.1.3 -param:MASTER_PORT=8181

Windows requires you to use quotes around the parameter otherwise the equals sign is treated as a space by the command interpreter:
c:\> pan.sh -file:/tmp/foo.ktr "-param:MASTER_HOST=192.168.1.3" "-param:MASTER_PORT=8181"




In job entries

In both the Job and Transformation job entries in a job you can define how parameters are set and/or passed:

As you can see from the screenshot all parameters defined in the parent job are passed down by default.  You can also selectively pass parameters down by specifying them in the grid.

You can either set the value of a parameter by giving it a value OR by looking up the value in a Result row from a previous transformation.   Simply specify a column name in that case.

In Mapping (execute sub-transformation) Step

You can pass named parameter values to sub-transformations in the 'Parameters' tab of the 'Mapping (execute sub-transformations)' step:
Atention:

As of PDI 4.2.x (?), the named parameter must be defined in the sub-transformation, otherwise the value set here will be ignored.

I find it worth mentioning that parameters passed via the command line MUST BE defined in the job to work. If you know this is the case, you can read it from the current description if you don't it is easily overlooked.

Comment: Posted by Jan Schreier at Mar 03, 2010 01:59

I must say that I have not found one place that explains how are you suppose to get the value from the named parameter within the job/transformation, this article explains only how to set a named parameter value.

I'm not sure on whether this is the place to elaborate on the issue, but I find no other candidate.

Comment: Posted by Dor Porat at Jan 05, 2011 01:09

In answer to Dor Porat: Open job PROPERTIES. Open the PARAMETERS Tab. Define your parameter here. It will then be available for insertion anywhere in the job, where you can use variables. F. i. you can set a variable and in the "value" field press ctrl-space, then insert your parameter from the drop-down list.

Comment: Posted by Jens Lærkedal at Jan 06, 2011 01:36

Jens -I am trying to use your suggestion, but I don't quite understand. The 'set variable' step has columns for 'field name' and 'variable name', but not 'value'. Ctrl+Space in either of those columns does nothing for me.

(edit) - OK - figured this out. I needed to use the 'get variable' step rather than 'set variable'

Comment: Posted by Steve Donie at Jan 17, 2011 13:52 Updated by Steve Donie

To use these parameters to make a connection dynamic, simply configure under "settings" the connection host, user, pass, etc. values as the variable (dollar sign, open curly brace, variable name, close curly brace ).

Comment: Posted by Neal Cowles at Jan 18, 2011 12:50

I was focused on the use of parameters in JOBS, where it is fairly obvious. As Steve points out, in order to use parameters in a TRANSFORMATION, you will need to apply "Get Variables", in order to "transform" the parameter values to "rows". The big advantage of parameters in a JOB is, that you can define them on a command line, from which you start Data-integration, and they are as easily accessible as variables from within the job.

Comment: Posted by Jens Lærkedal at Feb 08, 2011 07:45

My pre-existing non-Kettle application (PHP) uses environment variables to configure all manner of environment-specific stuff which the application references dynamically to ensure that it readily deploys in parallel configurations without re-coding.

I'd like to use named parameters to acheive the same level of environmental abstraction in Kettle and I can see that this is possible in Pan and Kitchen by using -param on their command lines via a shell script wrapper to map environment variable to named parameter. 

However, I cannot see that there is an equivalent facility for Carte which would be my preferred invocation mechanism in production. Any suggestions?

Comment: Posted by Howard Webb at Jun 23, 2011 04:31

Java API call version:    trans.addParameterDefinition("batchXmlFile", batchXmlFile, null);
trans.addParameterDefinition("MASTER_HOST", "192.168.1.3", null);

trans.addParameterDefinition("MASTER_PORT", "8181", null);

Comment: Posted by Darren Hartford at Jul 27, 2011 11:28