Kettle系列: kettle标准化trans模板

=============================
主控trans + sub trans 模式
=============================
针对一个具体的处理任务(比如增量加载一个表), 我认为应该最好是使用两个trans来完成这个任务,分别是主控trans 和sub trans, 其中主控trans负责流程控制(包括依赖检查+增量区间设定+异常报警), sub trans仅负责数据转换, 这样能很好地隔离控制逻辑和数据处理逻辑.

用到的组件有:
在主控trans中, 通过 Transformation executor 组件调用sub trans, 可以在Transformation executor 组件上设置传递的参数, 通常是增量处理的时间区间.
而在数据处理trans中通过Get rows from result 组件对应地也设置参数, 用来获取主控trans传入的参数.


=============================
Transformation executor 的异常捕获
=============================
一般情况下, 如果Transformation executor 执行错误, 在log中能看到错误日志, 但是主控trans却获取不到错误状态. 需要做一些特别设定才能捕获到sub trans的执行异常, 这包括:
1. 在transformation executor 界面的Execution results 页签上, 确保Number of errors设定了输出字段名.
2. 增加一个 Block this step until steps finish 组件来获取sub trans正常结束.
3. 增加一个 filter rows组件来判断 transformation executor 的错误数量输出字段是否大于0.
4. 在filter rows组件后加上 Abort 组件.


这里重点强调, 如何连接 transformation executor 组件和 Block 组件, 以及 transformation executor 组件和 filter组件.
1. 连接 transformation executor 组件和 Block组件
必须使用 this output will contain a copy of the executor steps input data 连线, 在trans的XML文件中, 该连线在对应着 executors_output_step tag.
2. 连接 transformation executor 组件和 filter组件
必须使用 This output will contain the execution results 连线,在trans的XML文件中, 该连线在对应着 execution_result_target_step tag.

<execution_result_target_step>check error filter</execution_result_target_step>
<execution_errors_field>ExecutionNrErrors</execution_errors_field>
<result_rows_target_step/>
<result_files_target_step/>
<executors_output_step>Blocking Step</executors_output_step>

因为 Kettle 7.1 的bug, 上面两个连线必须先连transformation executor 组件到 Block组件, 然后再连transformation executor 组件和 filter组件. 如果次序反了的话, trans的XML文件将会丢失 executors_output_step tag 的取值, 这样即使sub trans异常, 主控trans也捕获不到.

步骤比较繁琐也容易忘记, 贴一个操作步骤示意图.

 

下面是一个比较完整的组件示意图:

下图的abort组件也要打开abort as error, 这样才能将报错冒泡到最外层. 

 

原文地址:https://www.cnblogs.com/harrychinese/p/kettle_trans_template.html