Pentaho
Data Integration
完全自学手册
(孟菲斯著)
文档目录
文档目录 ...........................................................................................................................................
2
更新记录 ......................................................................................................................................... 17
第一章 .
KETTLE 基础介绍 ........................................................................................................ 18
1.1.
1.2.
1.3.
核心组件 ...............................................................................................................................
组成部分 ...............................................................................................................................
概念模型 ...............................................................................................................................
18
18
19
1.3.1.
1.3.2.
1.3.3.
Transformation (转换) .............................................................................................. 19
Steps(步骤) ...............................................................................................................
20
Hops (节点连接) ....................................................................................................... 20
Jobs(工作) ................................................................................................................
20
Variable (变量) ......................................................................................................... 21
1.3.5.1. 设置环境变量 ......................................................................................................................... 21
1.3.4.
1.3.5.
1.3.5.2. 设置变量 ................................................................................................................................. 21
1.4.
1.5.
查看版本 ...............................................................................................................................
选项设置 ...............................................................................................................................
第二章 .
KETTLE 环境搭建 ........................................................................................................ 25
2.1.
2.2.
2.1.3.
2.1.1.
2.1.2.
单机部署 ...............................................................................................................................
下载 kettle .....................................................................................................................
安装 kettle .....................................................................................................................
运行 Spoon ....................................................................................................................
集群部署 ...............................................................................................................................
1. Carte 简介 ..................................................................................................................................
2. Carte 部署配置 ..........................................................................................................................
22
23
25
25
25
25
26
26
26
2.1 启动方法 ............................................................................................................................................ 26
2.2 启动配置 ............................................................................................................................................ 26
2.3 Carte xml 文件配置详解 ..................................................................................................................... 27
2.3.1 slaveserver 节点 ........................................................................................................................... 28
2.3.2 masters 节点 ................................................................................................................................ 28
2.3.3 report_to_masters 节点 ............................................................................................................... 28
2.3.4 max_log_lines 节点 ...................................................................................................................... 28
2.3.5 max_log_timeout_minutes 节点 .................................................................................................. 28
2.3.6 object_timeout_minutes 节点 ..................................................................................................... 29
2.3.7 (*) repository 节点 ....................................................................................................................... 29
3. Carte 集群 ..................................................................................................................................
29
3.1 普通集群 ............................................................................................................................................ 30
3.2 动态集群 ............................................................................................................................................ 30
2.3.
运行方式 ...............................................................................................................................
30
转换执行器 Pan........................................................................................................... 30
2.3.1.
2.3.1.1.
Pan 参数介绍 ......................................................................................................................... 30
2.3.1.2.
Pan 实例讲解: Windows ...................................................................................................... 31
2.3.1.3.
Pan 实例讲解: Linux ............................................................................................................. 31
2.3.2.
2.3.2.1.
任务执行器 Kitchen ..................................................................................................... 32
Kitchen 参数介绍 ................................................................................................................... 32
2.3.2.2.
Kitchen 实例讲解: Windows ................................................................................................ 33
2.3.2.3.
Kitchen 实例讲解: Linux ....................................................................................................... 34
2.4.
定时任务 ...............................................................................................................................
Windows ........................................................................................................................
2.4.1.
2.4.2.
Linux ..............................................................................................................................
第三章 .
KETTLE 基本功能 ........................................................................................................ 40
35
35
35
3.1.
3.2.
3.3.
3.1.1.
3.1.2.
3.1.3.
3.1.4.
3.1.5.
3.1.6.
3.2.1.
3.2.2.
3.3.1.
3.3.2.
3.3.3.
3.3.4.
3.3.5.
40
40
40
新建转换 ...............................................................................................................................
方法 1............................................................................................................................
方法 2............................................................................................................................
方法 3............................................................................................................................
41
主对象树 ....................................................................................................................... 41
核心对象 ....................................................................................................................... 42
新建数据库连接 ........................................................................................................... 42
43
43
转换实例 ...............................................................................................................................
转换实例 1 ....................................................................................................................
转换实例 2 ....................................................................................................................
新建作业 ...............................................................................................................................
方法 1............................................................................................................................
方法 2............................................................................................................................
方法 3............................................................................................................................
45
主对象树 ....................................................................................................................... 45
核心对象 ....................................................................................................................... 46
46
作业实例 ...............................................................................................................................
作业实例 1 ....................................................................................................................
作业实例 2 ....................................................................................................................
46
46
43
44
44
44
3.4.
3.4.1.
3.4.2.
第四章 .
KETTLE 设计环境 ........................................................................................................ 46
4.1.
4.1.1.
TRANSFORMATION:转换步骤 (24-228)..................................................................................... 46
46
Csv file input ............................................................................................................................ 46
Input :输入 (38) ............................................................................................................
4.1.1.1.
4.1.1.1.1. 功能描述 ........................................................................................................................... 47
4.1.1.1.2. 操作步骤 ........................................................................................................................... 47
4.1.1.1.3. 实例讲解 ........................................................................................................................... 48
4.1.1.2.
DataGrid .................................................................................................................................. 48
4.1.1.3.
De-serialize from file :文件反序列化 .................................................................................... 48
4.1.1.4.
ESRI Shapefile Reader .............................................................................................................. 48
4.1.1.5.
Email messages input .............................................................................................................. 48
4.1.1.6.
Fixed file input ......................................................................................................................... 48
4.1.1.7.
GZIP CSV Input ......................................................................................................................... 48
4.1.1.8.
Generate Rows......................................................................................................................... 48
4.1.1.9.
Generate random credit card numbers ................................................................................... 48
4.1.1.10.
4.1.1.11.
4.1.1.12.
4.1.1.13.
4.1.1.14.
Generate random value ...................................................................................................... 49
Get File Names .................................................................................................................... 49
Get Files Rows Count ........................................................................................................... 49
Get SubFolder names .......................................................................................................... 49
Get System Info:获取系统信息 ....................................................................................... 49
4.1.1.14.1. 功能描述 ......................................................................................................................... 50
4.1.1.14.2. 操作步骤 ......................................................................................................................... 51
4.1.1.14.3. 实例讲解 ......................................................................................................................... 52
4.1.1.15.
4.1.1.16.
4.1.1.17.
4.1.1.18.
4.1.1.19.
4.1.1.20.
4.1.1.21.
4.1.1.22.
4.1.1.23.
4.1.1.24.
4.1.1.25.
Get data from XML .............................................................................................................. 53
Get repository names .......................................................................................................... 53
Get table names .................................................................................................................. 53
Google Analytics.................................................................................................................. 53
HL7 Input ............................................................................................................................. 53
JSON Input........................................................................................................................... 53
LDAP Input .......................................................................................................................... 53
LDIF Input ............................................................................................................................ 54
Load file content in memory ............................................................................................... 54
Microsoft Access input ........................................................................................................ 54
Microsoft Excel Input .......................................................................................................... 54
4.1.1.25.1. 功能描述 ......................................................................................................................... 54
4.1.1.25.2. 操作步骤 ......................................................................................................................... 54
4.1.1.25.2.1. 指定文件名 .............................................................................................................. 55
4.1.1.25.2.2. 指定内容 .................................................................................................................. 55
4.1.1.25.2.3. 字段 .......................................................................................................................... 55
4.1.1.25.2.4. 错误处理 .................................................................................................................. 55
4.1.1.25.2.5. 其他输出字段 .......................................................................................................... 55
4.1.1.25.3. 实例讲解 ......................................................................................................................... 55
4.1.1.26.
4.1.1.27.
4.1.1.28.
4.1.1.29.
4.1.1.30.
4.1.1.31.
4.1.1.32.
Mondrian Input ................................................................................................................... 55
OLAP Input .......................................................................................................................... 56
Property Input ..................................................................................................................... 56
RSS Input ............................................................................................................................. 56
S3 CSV Input ........................................................................................................................ 56
SAP Input ............................................................................................................................. 56
SAS Input ............................................................................................................................. 56
4.1.1.33.
SalesForce Input .................................................................................................................. 56
4.1.1.34.
Table input :表输入 ............................................................................................................... 56
4.1.1.34.1. 功能描述 ......................................................................................................................... 56
4.1.1.34.2. 操作步骤 ......................................................................................................................... 57
4.1.1.34.3. 实例讲解 ......................................................................................................................... 58
4.1.1.35.
Text file input :文本文件输入 ............................................................................................... 58
4.1.1.35.1. 功能描述 ......................................................................................................................... 58
4.1.1.35.2. 操作步骤 ......................................................................................................................... 58
4.1.1.35.2.1. 文件名称指定 .......................................................................................................... 58
4.1.1.35.2.2. 从先前的步骤中接受文件名 .................................................................................. 59
4.1.1.35.2.3. 内容指定 .................................................................................................................. 59
4.1.1.35.2.4. 错误处理 .................................................................................................................. 62
4.1.1.35.2.5. 过滤 .......................................................................................................................... 63
4.1.1.35.2.6. 字段 .......................................................................................................................... 64
4.1.1.35.2.7. 其他输出字段 .......................................................................................................... 65
4.1.1.35.3. 格式化 ............................................................................................................................. 65
4.1.1.35.3.1. Number 格式化 ....................................................................................................... 65
4.1.1.35.3.2. Date 格式化 ............................................................................................................. 66
4.1.1.35.3.3. 其它 .......................................................................................................................... 66
4.1.1.35.4. 实例讲解 ......................................................................................................................... 67
4.1.1.36.
XBase input: XBase输入 ................................................................................................... 67
4.1.1.36.1. 功能描述 ......................................................................................................................... 67
4.1.1.37.
XML Input Stream(StAX) ..................................................................................................... 67
4.1.1.37.1. 功能描述 ......................................................................................................................... 67
4.1.1.38. Yaml Input ................................................................................................................................ 69
4.1.2.
Output :输出 (22) ......................................................................................................... 69
4.1.2.1.
Automatic Documentation Output .......................................................................................... 69
4.1.2.2.
Delete:删除 .......................................................................................................................... 69
4.1.2.2.1. 功能描述 ........................................................................................................................... 69
4.1.2.2.2. 操作步骤 ........................................................................................................................... 69
4.1.2.3.
Insert / Update :插入 / 更新 ................................................................................................... 70
4.1.2.3.1. 功能描述 ........................................................................................................................... 70
4.1.2.3.2. 操作步骤 ........................................................................................................................... 71
4.1.2.4.
JSON Output ............................................................................................................................ 72
4.1.2.5.
LDAP Output ............................................................................................................................ 72
4.1.2.6.
Mircosoft Access Output ......................................................................................................... 72
4.1.2.7.
Mircosoft Excel Output :Excel 输出 ....................................................................................... 72
4.1.2.7.1. 功能描述 ........................................................................................................................... 72
4.1.2.7.2. 操作步骤 ........................................................................................................................... 72
4.1.2.8.
Pentaho Reporting Output....................................................................................................... 75
4.1.2.9.
Properties Output .................................................................................................................... 75
4.1.2.10.
RSS Output .......................................................................................................................... 75
4.1.2.11.
4.1.2.12.
4.1.2.13.
4.1.2.14.
4.1.2.15.
4.1.2.16.
4.1.2.17.
S3 File Output...................................................................................................................... 75
SQL File Output ................................................................................................................... 75
Saleforce Delete .................................................................................................................. 75
Saleforce Insert ................................................................................................................... 75
Saleforce Update ................................................................................................................. 75
Saleforce Upsert .................................................................................................................. 75
Serialize to file ..................................................................................................................... 75
4.1.2.18.
Synchronize after merge ..................................................................................................... 76
4.1.2.19.
Table output ............................................................................................................................ 76
4.1.2.19.1. 功能描述 ......................................................................................................................... 76
4.1.2.19.2. 操作步骤 ......................................................................................................................... 77
4.1.2.20.
Text file output :文本文件输出 ............................................................................................. 79
4.1.2.20.1. 功能描述 ......................................................................................................................... 79
4.1.2.20.2. 操作步骤 ......................................................................................................................... 80
4.1.2.21.
Update:更新 ..................................................................................................................... 81
4.1.2.21.1. 功能描述 ......................................................................................................................... 81
4.1.2.21.2. 操作步骤 ......................................................................................................................... 82
4.1.2.22.
XML Output ......................................................................................................................... 83
4.1.3.
4.1.3.1.
Transform :转换 (26) .................................................................................................... 84
Add XML .................................................................................................................................. 84
4.1.3.2.
Add a checksum ....................................................................................................................... 84
4.1.3.3.
Add constants:增加常量 ...................................................................................................... 84
4.1.3.3.1. 功能描述 ........................................................................................................................... 84
4.1.3.3.2. 操作步骤 ........................................................................................................................... 84
4.1.3.4.
Add sequence .......................................................................................................................... 85
4.1.3.4.1. 功能描述 ........................................................................................................................... 85
4.1.3.4.2. 操作步骤 ........................................................................................................................... 85
4.1.3.5.
Add value fields changing seqence .......................................................................................... 86
4.1.3.6. !Calculator:计算器 ............................................................................................................. 86
4.1.3.6.1. 功能描述 ........................................................................................................................... 87
4.1.3.6.2. 操作步骤 ........................................................................................................................... 88
4.1.3.7.
Closure Generator.................................................................................................................... 89
4.1.3.8.
Concat Fields ............................................................................................................................ 89
4.1.3.9.
Get ID From slave server .......................................................................................................... 89
4.1.3.10.
4.1.3.11.
Number range ..................................................................................................................... 89
Replace in string:字符串替换 .......................................................................................... 89
4.1.3.11.1. 功能描述 ......................................................................................................................... 89
4.1.3.11.2. 操作步骤 ......................................................................................................................... 89
4.1.3.12.
!Row Normaliser :行转列 ............................................................................................... 90
4.1.3.12.1. 功能描述 ......................................................................................................................... 90
4.1.3.12.2. 操作步骤 ......................................................................................................................... 91
4.1.3.13.
Row denormaliser:列转行 ............................................................................................... 92
4.1.3.13.1. 功能描述 ......................................................................................................................... 92
4.1.3.13.2. 操作步骤 ......................................................................................................................... 92
4.1.3.14.
!Row flattener :行扁平化 ............................................................................................... 92
4.1.3.14.1. 功能描述 ......................................................................................................................... 93
4.1.3.14.2. 操作步骤 ......................................................................................................................... 93
4.1.3.15.
!Select values:字段选择 ................................................................................................ 94
4.1.3.15.1. 功能描述 ......................................................................................................................... 94
4.1.3.15.2. 操作步骤 ......................................................................................................................... 95
4.1.3.16.
Set field value ...................................................................................................................... 96
4.1.3.17.
4.1.3.18.
Set field value to a constant ................................................................................................ 96
Sort rows ............................................................................................................................. 96
4.1.3.18.1. 功能描述 ......................................................................................................................... 96
4.1.3.18.2. 操作步骤 ......................................................................................................................... 96
4.1.3.19.
Split Fields:拆分字段 .......................................................................................................... 97
4.1.3.19.1. 功能描述 ......................................................................................................................... 97
4.1.3.19.2. 操作步骤 ......................................................................................................................... 97
4.1.3.20.
4.1.3.21.
4.1.3.22.
Split Fields to rows .............................................................................................................. 99
String operations ................................................................................................................. 99
String cut:裁剪字符串 ..................................................................................................... 99
4.1.3.22.1. 功能描述 ......................................................................................................................... 99
4.1.3.22.2. 操作步骤 ......................................................................................................................... 99
4.1.3.23.
Unique rows :去除重复记录 .......................................................................................... 100
4.1.3.23.1. 功能描述 ....................................................................................................................... 100
4.1.3.23.2. 操作步骤 ....................................................................................................................... 100
4.1.3.25.
!Value Mapper :值映射 ................................................................................................ 101
4.1.3.25.1. 功能描述 ....................................................................................................................... 101
4.1.3.25.2. 操作步骤 ....................................................................................................................... 101
4.1.3.26.
XSL Transformation ........................................................................................................... 103
4.1.4.
Utility(15) .................................................................................................................... 103
4.1.4.1.
Change file encoding ............................................................................................................. 103
4.1.4.2.
Clone row ............................................................................................................................... 103
4.1.4.3.
Delay row ............................................................................................................................... 103
4.1.4.4.
Edit to xml .............................................................................................................................. 103
4.1.4.5.
Execute a process .................................................................................................................. 103
4.1.4.6.
If field value is null ................................................................................................................. 103
4.1.4.7.
Mail ........................................................................................................................................ 103
4.1.4.8.
Metadata structure of stream ............................................................................................... 103
4.1.4.9.
Null if :设置为空值 .............................................................................................................. 103
4.1.4.9.1. 功能描述 ......................................................................................................................... 103
4.1.4.10.
4.1.4.11.
Process files ....................................................................................................................... 104
Run SSH commands .......................................................................................................... 104
4.1.4.12.
Send message to Syslog .................................................................................................... 104
4.1.4.13.
Table Compare ....................................................................................................................... 104
4.1.4.14. Write to log ............................................................................................................................ 104
4.1.4.15.
Zip file................................................................................................................................ 104
4.1.4.15.1. 功能描述 ....................................................................................................................... 104
4.1.4.15.2. 操作步骤 ....................................................................................................................... 104
4.1.5.
Flow(16) ...................................................................................................................... 106
4.1.5.1.
Abort :中止 .......................................................................................................................... 106
4.1.5.1.1. 功能描述 ......................................................................................................................... 106
4.1.5.2.
Annotate Stream.................................................................................................................... 106
4.1.5.3.
Append streams:追加流 ..................................................................................................... 106
4.1.5.3.1. 功能描述 ......................................................................................................................... 106
4.1.5.3.2. 操作步骤 ......................................................................................................................... 106
4.1.5.4.
Block this step unitil steps finish ............................................................................................ 107
4.1.5.5.
Blocking Step:阻塞数据 ...................................................................................................... 107
4.1.5.5.1. 功能描述 ......................................................................................................................... 107
4.1.5.5.2. 操作步骤 ......................................................................................................................... 107
4.1.5.6.
Detect empty stream ............................................................................................................. 108
4.1.5.7.
Dummy (do nothing) :空操作(什么也不做) .................................................................. 108
4.1.5.7.1. 功能描述 ......................................................................................................................... 108
4.1.5.8.
ETL Metadata Injection .......................................................................................................... 109
4.1.5.9. !Filter rows: 过滤记录(过滤行) ................................................................................... 109
4.1.5.9.1. 功能描述 ......................................................................................................................... 109
4.1.5.9.2. 操作步骤 ......................................................................................................................... 109
4.1.5.10.
4.1.5.11.
4.1.5.12.
4.1.5.13.
4.1.5.14.
Identify last row in a stream .............................................................................................. 110
Java fileter ......................................................................................................................... 111
Job Executor ...................................................................................................................... 111
Prioritize streams .............................................................................................................. 111
Single Threader ................................................................................................................. 111
4.1.5.15.
Switch / Case ..................................................................................................................... 111
4.1.5.15.1. 功能描述 ....................................................................................................................... 111
4.1.5.15.2. 操作步骤 ....................................................................................................................... 111
4.1.5.16.
Transformation Executor ....................................................................................................... 113
4.1.6.
Scripting(9) .................................................................................................................. 113
4.1.6.1. !Execute SQL script:执行 SQL脚本 .................................................................................. 113
4.1.6.1.1. 功能描述 ......................................................................................................................... 113
4.1.6.1.2. 操作步骤 ......................................................................................................................... 114
4.1.6.1.3. 实例讲解 ......................................................................................................................... 115
4.1.6.2.
Execute row SQL script:执行 SQL脚本(字段流替换) ................................................... 116
4.1.6.2.1. 功能描述 ......................................................................................................................... 116
4.1.6.2.2. 操作步骤 ......................................................................................................................... 116
4.1.6.3.
Formula.................................................................................................................................. 117
4.1.6.4. !Modified Java Script Value ................................................................................................. 118
1)
2)
3)
Transformation scripts ................................................................................................................ 118
Transformation constants ........................................................................................................... 118
Transformation functions ........................................................................................................... 118
1) 过滤 Null 字段 ........................................................................................................................... 119
2) 字符串截取 ................................................................................................................................ 119
3) 过滤记录行,控制转换流程 .................................................................................................... 119
4) 使用 java 类库 ........................................................................................................................... 119
4.1.6.4.1. 实例讲解 ......................................................................................................................... 124
4.1.6.5.
Regex Evaluation .................................................................................................................... 124
4.1.6.6.
Rules Accumulator ................................................................................................................. 124
4.1.6.7.
Rules Executor ....................................................................................................................... 124
4.1.6.8.
User Defined Java Class ......................................................................................................... 124
4.1.6.9.
User Defined Java Expression ................................................................................................ 124
4.1.7.
BA Server(3) ................................................................................................................ 125
4.1.7.1.
Call endpoint .......................................................................................................................... 125
4.1.7.2.
Get session varables .............................................................................................................. 125