Article directory
- foreword
- Kettle takes yesterday's time & sets any time variable
- Dynamic table name query data:
- 1. Get the table name
-
- 1. Create a conversion getTableName, drag in `get system information, field selection, set variables`
- 2. Open the edit interface for obtaining system information, fill in the name, click the type to select the type of information to be obtained
- 3. Open `Field Selection`, select `Metadata`, and set field properties
- 4. Open the setting variable, fill in the relevant information, or click Get Field to automatically fill in the field information
- 2. Update data according to the table name
-
- 1. Open the table input, select the database, fill in the sql statement, use the ${TODAY} variable set before, and check to replace the variable in the SQL statement, otherwise the variable will not take effect
- 2. Open Insert/Update, specify the target table, fill in the query keywords, and fill in the update fields
- 3. Job execution conversion
- Summarize
foreword
Requirements:
There is an information table in the database, and information is recorded every day. The amount of data is large, and a table is created every day for storage.
The name of the table changes every day, and the information needs to be obtained from the table of the day and synchronized to the specified database.
Scheduled format:
tableName_yyyyMMdd ( abcd_20230701 )
This test environment:
system | Windows10 |
Software version | kettle 7.1.0.0-12 |
MySQL driver | mysql-connector-java-8.0.19.jar |
Kettle takes yesterday's time & sets any time variable
Dynamic table name query data:
- The first transformation settings table named variable
- The second level of conversion is to get the variables and bring them into sql to query the data
1. Get the table name
1. Create a conversion getTableName, drag it in获取系统信息,字段选择,设置变量
2. Open the edit interface for obtaining system information, fill in the name, click the type to select the type of information to be obtained
3. Open 字段选择
, select 元数据
, and set field properties
4. Open the setting variable, fill in the relevant information, or click Get Field to automatically fill in the field information
表名转换
It ends here.
2. Update data according to the table name
The implementation steps are as follows:
- Create a new conversion autoQuery, drag it in
表输入
,插入/更新
- Table operations need to connect to the database. This time Kettle uses the 8.x version of the MySQL driver
1. Open the table input, select the database, fill in the sql statement, use the ${TODAY} variable set before, and check to replace the variable in the SQL statement, otherwise the variable will not take effect
2. Open Insert/Update, specify the target table, fill in the query keywords, and fill in the update fields
This is the end of the data conversion based on the table name update.
3. Job execution conversion
- Create a new job autoTable, drag it into START, first call to get the table name conversion, then call the update data conversion based on the table name, and finally drag it in successfully
- Save the job and run it.
Summarize
If this article is helpful to you, I hope that the big guys can
关注
,点赞
,收藏
,评论
support a wave, thank you very much!
Please correct me if I am wrong!!!