kettle---用户手册(7:变量)

本文介绍了在Kettle中如何定义及使用变量,包括在转换和job中的应用。详细解释了如何通过setVariable设置变量,以及如何从kettle.properties文件中读取变量。此外,还列举了一些内部已定义的变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我觉得这一章是比较重要的,在kettle中定义变量。

变量可以用在PDI的任何地方,包括转换和job。

通过set Variable在转换或者job中设置变量,也可以设置在kettle.properties文件中,不过,kettle.properties文件要放在以下位置:

$HOME/.kettle (Unix/Linux/OSX)
C:\Documents and Settings\<username>\.kettle\ (Windows)
C:\Users\<username>\.kettle\ (Windows Vista)

我们可以通过使用“Get Variable”step(在job里)来获取变量。
也可以通过•${VARIABLE}(unix)或者•%%VARIABLE%%(windows)获取变量。这两种方式甚至可以混用。


变量的作用域:
环境变量(不建议用)

The first usage (and only usage in previous Kettle versions) was to set an environment variable. Traditionally, this was accomplished by passing options to the Java Virtual Machine (JVM) with the -D option. It's also an easy way to specify the location of temporary files in a platform independent way, for example using variable ${java.io.tmpdir}. This variable points to directory /tmp on Unix/Linux/OSX and to C:\Documents and Settings\<username\Local Settings\Temp on Windows machines. The only problem with using environment variables is that the usage is not dynamic and problems arise if you try to use them in a dynamic way. For example, if you run two or more transformations or jobs run at the same time on an application server (for example the Pentaho platform) you get conflicts. Changes to the environment variables are visible to all software running on the virtual machine.

kettle变量:

内部已有变量:

下面的变量是已经定义的:

The following variables are always defined:

Variable NameSample value
Internal.Kettle.Build.Date2007/05/22 18:01:39
Internal.Kettle.Build.Version2045
Internal.Kettle.Version2.5.0

These variables are defined in a transformation:

Variable NameSample value
Internal.Transformation.Filename.DirectoryD:\Kettle\samples
Internal.Transformation.Filename.NameDenormaliser - 2 series of key-value pairs.ktr
Internal.Transformation.NameDenormaliser - 2 series of key-value pairs sample
Internal.Transformation.Repository.Directory/

These are the internal variables that are defined in a Job:

Variable NameSample value
Internal.Job.Filename.Directory/home/matt/jobs
Internal.Job.Filename.NameNested jobs.kjb
Internal.Job.NameNested job test case
Internal.Job.Repository.Directory/

These variables are defined in a transformation running on a slave server, executed in clustered mode:

Variable NameSample value
Internal.Slave.Transformation.Number0..<cluster size-1> (0,1,2,3 or 4)
Internal.Cluster.Size<cluster size> (5)




转载于:https://www.cnblogs.com/aomi/archive/2013/05/18/3085101.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值