Using named parameters

In the last exercise, you used two variables: one created in the kettle.properties file, and the other created inside of Spoon at runtime. There are still more ways to define variables. One of them is to create a named parameter. Named parameters are variables that you define in a transformation, and they can have a default value. You only have to supply a value if it differs from the default. Let's look at how it works, as follows:

  1. Open the last transformation (if you had closed it).
  2. Double-click anywhere in the work area excepting over the steps or hops. This will open the Transformation properties window.
  1. Click on the Variables tab. This is where we define the named parameters.
  2. Fill in the grid as shown, replacing the path in the example with the real path where you have PDI installed:
Defining a named parameter
  1.  Close the window.
  2. Double-click on the CSV file input step. Replace the full path of the location of the file with the following: ${SAMPLES_DIR}/Zipssortedbycitystate.csv.
  3. Close the window and save the transformation.
  1. Click F9 to run the transformation. The Parameters tab in the Run Options window will show the named parameter that we just defined:
Running a transformation with a named parameter
  1. Click on Run. PDI will replace the value of the variable, exactly as it did before.

Note that this time, we didn't supply a value for the variable, as it already had a proper value. Now, suppose that we move the samples folder to a different location. The following describes how we can provide the new value:

  • Click F9 to run the transformation. 
  • In the Parameters tab, fill in the Value column with the proper value, as shown in the following screenshot:
Supplying a value for a named parameter
  • Click on RunPDI will replace the value of the variable with the value that you provided, and will read the file from that location.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset