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
to 10
, incrementing by 1
, as in 0, 1,..., 10
. 0
to 100
, incrementing by 20
, as in 0, 20, 40,..., 100
. 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.
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.
Carry out the following steps:
gen_sequence.ktr
. 1
in the first row and a 10
in the second row. gen_sequence.ktr
. 0
in the first row and a 100
in the second. INCREMENT
under Parameter and 20
under Value. gen_sequence.ktr
. 50
in the first row and a 500
in the second. INCREMENT
under Parameter and 50
under Value.sequence_1_10_1.txt
sequence_0_100_20.txt
sequence_50_500_50.txt
0, 1,..., 10
in the first file, 0, 20, 40,..., 100
in the second, and 100, 200,.., 500
in the third, just as expected.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.
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.