当前位置:网站首页>RestCloud ETL抽取動態庫錶數據實踐
RestCloud ETL抽取動態庫錶數據實踐
2022-06-26 15:04:00 【RestCloud】

RestCloud ETL社區版是一款數據集成工具,提供可視化多數據管道構建、數據源管理、運行監控及權限管理功能。
1.場景說明:
對於一些業務系統每天運行自動產生一張新數據錶,希望通過1條數據流程每天自動讀取當天的數據錶。如2022年6月1日產生錶名稱為“table_20220601”,2022年6月2日產生錶名稱為“table_20220602”,以此類推;對於這樣的動態錶,如何使用RestCloud ETL簡單、便捷實現數據抽取。
2.實現原理:
首先我們需要根據日期自動生成對於的錶名稱,並做將該參數傳輸給庫錶輸入組件。實現流程圖如下:

實現該業務的前提條件是庫錶輸入組件支持接收變量傳輸,這個RestCloud ETL無與倫比的優勢。
3.實現步驟:
3.1配置"執行Java脚本"
右鍵"執行Java脚本",點擊“節點屬性”打開配置編輯頁面,點擊下一步,編輯Java代碼。代碼中加入生成錶名稱代碼,輸出參數為: p_tablename ,如下圖:

代碼如下:
package cn.restcloud.etl.rule.ext;
import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import java.sql.Connection;
import cn.restcloud.framework.core.context.*;
import cn.restcloud.etl.base.IETLBaseEvent;
import cn.restcloud.etl.base.IETLBaseProcessEngine;
import cn.restcloud.framework.core.util.*;
import cn.restcloud.framework.core.util.db.rdb.*;
import java.util.*;
import java.text.SimpleDateFormat;
/**
indoc為流數據
執行成功必須返回字符1,返回0錶示終止流程
*/
public class ETL_T00005_1INWBJPUXVB implements IETLBaseEvent {
@Override
public String execute(IETLBaseProcessEngine engine, Document modelNodeDoc, Document indoc,String fieldId,String params) throws Exception {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String table = "table_" + sdf.format(date);
PrintUtil.o(table);
indoc.put("p_tablename",table);
return "1";
}
}
完成代碼編輯,點擊【編譯並保存】退出配置。
3.2 庫錶輸入配置
右鍵"庫錶輸入",點擊“節點屬性”打開配置編輯頁面。
選擇源錶數據源,點擊下一步:

編輯讀取數據SQL語句,select * from 錶名稱,錶名稱輸入接收參數,參數格式:${參數},${p_tablename},點擊下一步:

點擊【新增字段】,輸入抽取數據錶字段,點擊保存完成配置。
3.3 庫錶輸出配置
右鍵"庫錶輸入",點擊“節點屬性”打開配置編輯頁面。


依次輸入配置,選擇數據源,載入數據庫錶,選擇數據庫錶。

點擊【從錶中讀入】,勾選關鍵字(主鍵),點擊下一步。

根據需要選擇對應的日記策略,點擊保存完成配置。
4.運行測試
點擊【運行】

點擊【開始運行】

5.查看運行結果

點擊庫錶輸出,數據傳輸統計


感謝您對我們的關注和支持!如需了解更多的功能,請加入RestCloud ETL社區免費下載體驗,下載地址:https://etl.restcloud.cn
边栏推荐
- MySQL master-slave replication and read-write separation
- How to mount cloud disks in ECS
- 重磅白皮书发布,华为持续引领未来智慧园区建设新模式
- NAACL2022:(代码实践)好的视觉引导促进更好的特征提取,多模态命名实体识别(附源代码下载)...
- Mark: unity3d cannot select resources in the inspector, that is, project locking
- Informatics Olympiad 1405: sum and product of prime numbers (thinking problem)
- Numpy基本使用
- Where do people get their top energy?
- R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、使用aggregate.data.frame函数计算分组汇总统计信息
- JVM 输出 GC 日志导致 JVM 卡住,我 TM 人傻了
猜你喜欢

Program analysis and Optimization - 8 register allocation

Minister of investment of Indonesia: Hon Hai is considering establishing electric bus system and urban Internet of things in its new capital

Common operation and Principle Exploration of stream

TS常用数据类型总结

【使用yarn运行报错】The engine “node“ is incompatible with this module.

710. random numbers in the blacklist

Halcon C# 设置窗体字体,自适应显示图片

View touch analysis

聊聊 RPA 方向的规划:简单有价值的事情长期坚持做

Use abp Zero builds a third-party login module (I): Principles
随机推荐
TCP 复位攻击原理
NAACL2022:(代码实践)好的视觉引导促进更好的特征提取,多模态命名实体识别(附源代码下载)...
Program analysis and Optimization - 8 register allocation
人力资源导出数据 excel VBA
R language dplyr package bind_ The rows function merges the rows of the two dataframes vertically. The final number of rows is the sum of the rows of the original two dataframes (combine data frames)
重磅白皮书发布,华为持续引领未来智慧园区建设新模式
这才是优美的文件系统挂载方式,亲测有效
Informatics Olympiad all in one 1400: count the number of words (string matching)
集群中命令的执行过程
Mark: unity3d cannot select resources in the inspector, that is, project locking
券商经理给的开户链接办理股票开户安全吗?我想开个户
Pod scheduling of kubernetes
One copy ten, CVPR oral was accused of plagiarizing a lot, and it was exposed on the last day of the conference!
Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution
Redis cluster messages
vue中缓存页面 keepAlive使用
TS common data types summary
Notes on writing questions in C language -- table tennis competition
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
Redis transaction and watch instruction