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:
- Open the last transformation (if you had closed it).
- Double-click anywhere in the work area excepting over the steps or hops. This will open the Transformation properties window.
- Click on the Variables tab. This is where we define the named parameters.
- 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
- Close the window.
- 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.
- Close the window and save the transformation.
- 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
- 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 Run. PDI will replace the value of the variable with the value that you provided, and will read the file from that location.