Let's modify the transformation so that the starting date depends on a parameter.
START_DATE
with default value 01/12/1999
. start_date
. Under Variable write ${START_DATE}
. As Type select Date
, and under Format select or type dd/MM/yyyy
. date>=start_date and date<=31/12/2020
. start_date
field.You added a starting date as a named parameter. Then you read that variable into a new field and used it to keep only the dates that are greater or equal to its value.
As you just saw, the Get Variables step allows you to get the value of one or more variables. In the main tutorial you saw how to use the step at the beginning of a stream. Now you saw how to use it in the middle. The following is the dataset after the Get Variables step for this last exercise:
With the Get Variables step, you can read any Kettle variable—variables defined in the kettle.properties
file, internal variables as for example ${user.dir}
, named parameters as in this tutorial, or variables defined in another transformation (you haven't yet learned about these variables but you will soon).
As you know, the type of Kettle variables is String
by default. However, at the time you get a variable, you can change its metadata. As an example of that, in this last exercise you converted ${START_DATE}
to a Date
by using the mask dd/MM/yyyy
.
Note that you specified the variables as ${name of the variable}
. You could have used %%name of the variable%%
also. The full specification of the name of a variable allows you to mix variables with plain text.
Suppose that instead of a date you create a parameter named YEAR
with default value 1950
.
In the Get variables step you may specify 01/01/${YEAR}
as the value.
When you execute the transformation, this text will be expanded to 01/01/1950
or to 01/01/
plus the year you enter if you overwrite the default value.
Modify the time dimension generation by doing the following:
Name of month, Short name of month
, and Quarter
. start_year
and end_year
. Modify the transformation so that it generates dates only between those years. In other words, you have to discard dates out of that range. You may assume that the parameters will be between 1900 and 2020.There are some Kettle predefined variables that hold information about the logged in user: user.country, user.language
, etc. The following tasks involve the use of some of those variables. Which of the tasks can be accomplished without using a Get Variables step or a JavaScript step (Remember from the previous chapter that you can also get the value for a Kettle variable with a Javascript step):
a. Create a file named hello_<user>.txt
, where<user>
is the name of the logged user.
b. Create a file named hello.txt
that contains a single line with the text Hello, <user>!, <user>
being is the name of the logged user.
c. Write to the log (by using the Write to log step) a greeting message like Hello, user!
. The message has to be written in a different language depending on the language of the logged user.
d. All of the above
e. None of the above
3.129.20.133