Executing a job or a transformation by setting static arguments and parameters

When you develop a transformation which reads command-line arguments or defines named parameters, you usually intend to call it more than once with different values for those parameters or arguments. If you know the values beforehand, then there is an easy way to call the transformation, as you will see in this recipe.

Suppose that you want to create the following three files:

  1. First file: Numbers from 1 to 10, incrementing by 1, as in 0, 1,..., 10.
  2. Second file: Numbers from 0 to 100, incrementing by 20, as in 0, 20, 40,..., 100.
  3. Third file: Numbers from 100 to 500, incrementing by 100, as in 100, 200,.., 500.

You have a transformation that generates sequences like these. You just have to call it three times with the proper arguments and parameters.

Getting ready

You need the sample transformation that generates a file with a sequence described in the introduction.

Make sure you have defined the variable ${OUTPUT_FOLDER} with the name of the destination folder. Also, make sure that the folder exists.

How to do it...

Carry out the following steps:

  1. Create a job.
  2. Drag a Start job entry and three Transformation job entries into the canvas. Link all the entries, one after the other.
  3. Double-click on the first Transformation entry.
  4. As Transformation filename, browse to and select the sample transformation gen_sequence.ktr.
  5. Select the Argument tab and fill the grid with a 1 in the first row and a 10 in the second row.
  6. Double-click on the second Transformation entry.
  7. As Transformation filename, select the sample transformation gen_sequence.ktr.
  8. Select the Argument tab and fill the grid with a 0 in the first row and a 100 in the second.
  9. Select the Parameters tab. In the first row of the grid, type INCREMENT under Parameter and 20 under Value.
  10. Double-click on the last Transformation entry.
  11. As Transformation filename, select the sample transformation gen_sequence.ktr.
  12. Select the Argument tab and fill the grid with a 50 in the first row and a 500 in the second.
  13. Select the Parameters tab. In the first row of the grid, type INCREMENT under Parameter and 50 under Value.
  14. Save and run the job.
  15. Check the output folder. You will find the following three files:
    • sequence_1_10_1.txt
    • sequence_0_100_20.txt
    • sequence_50_500_50.txt
  16. Edit the files. You will see that they contain the sequences of numbers 0, 1,..., 10 in the first file, 0, 20, 40,..., 100 in the second, and 100, 200,.., 500 in the third, just as expected.

How it works...

When you run a transformation from a job, you have to specify at least the name and location of the transformation. There are however, a couple of extra settings that may be useful. In this recipe, you saw the use of the Argument and the Parameters tabs.

The Argument tab is used for sending command-line arguments to the transformation.

The grid in the Argument tab is equivalent to the Arguments grid you see when you run a transformation from Spoon. Each row belongs to a different command-line argument.

In this case, your transformation expected two command-line arguments: the limits from and to of the sequence. In the recipe, you set values for those arguments the Argument tab of each Transformation entry setting window.

The Parameters tab is used for setting values for the named parameters defined in the transformation. The grid under the Parameters tab is equivalent to the Parameters grid you see when you run a transformation from Spoon. Each row belongs to a different named parameter. You only have to provide values if they are different to the default values.

In this case, your transformation defined one named parameter: INCREMENT with a default value of 1. Therefore, you skipped the setting of this parameter in the first Transformation entry, but set values in the others.

Note

Note that if you set arguments or parameters in the Transformation entry setting window, the corresponding argument or parameters sent from the command line will be ignored if you run the job with Kitchen.

There's more...

All that was said for the Transformation job entry is also valid for Job job entries. That is, you can use the Argument and Parameters tab in a Job entry to send fixed values for command-line arguments or named parameters to the job.

See also

The recipe named Executing a job or a transformation from a job by setting arguments and parameters dynamically in this chapter. Here you will find directions on setting arguments and parameters at runtime.

..................Content has been hidden....................

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