-
在Modified Java Script Value组件中修改字段的值
-
kettle闪退问题
问题:在执行一个etl的过程中,当跑到接近100万数据的时候,kettle就自动退出了
解决:在安装目录下D:\PDI\pdi-ce-4.1.0-stable\data-integration\,有出错日志hs_err_pid252.log

日志中显示为outofmemory,在将Spoon.bat文件中的启动参数改大一倍后,结果还是一样。-Xmx参数超过1024m时,又提示无法创建虚拟机。。。
试着在linux服务器上,将kitchen.sh中参数JAVAMAXMEM调大,然后使用kitchen命令来运行此job,结果一切正常。
进入到kitchen.sh所在目录,执行如下命令:
./kitchen.sh -rep 192.168.0.13.PDI_Repository -user username -pass password -dir / -job Job_1 -
实现远程调用更新cognos中的模型文件
需求:在linux服务器etl抽取完数据之后,需要通过远程调用更新windows服务器上相对应的cognos模型文件。
实现步骤:
1、从linux上telnet登录到windows服务器
2、执行windows服务器上的更新脚本
在第一步中,需要使用autoexpect,它用来记录你输入的命令生成一个脚本,下次只要执行此脚本便能重现telnet登录并执行程序的过程。
autoexpect -p -f updatecubemain.exp telnet-p 使autoexpect只找寻最后的输出
-f 将录制脚本命名为“updatecubemain.exp”在执行完后,输入“exit”退出telnet,脚本自动生成。
遇到的几个问题:
- 在kettle中使用shell组件,想使用命令直接调用updatecubemain.exp,结果一直提示找不到目录。后来在linux中,/home/hadoop/.kettle/kettle.properties文件中加入KETTLE_HOME变量(KETTLE_HOME = /pentaho/pentaho/data-integration/),然后将updatecubemain.sh放在KETTLE_HOME对应的路径下。
updatecubemain.sh的内容为:
cd /home/hadoop/
./updatecubemain.exp - 在远程登录Windows服务器之后,直接执行需要更新的批处理文件无效,其中包含了一些cognos命令。需要做个中转,先在Windows服务器上建立一个任务计划,通过任务计划来调用此脚本。此处是将调用任务计划的脚本写在了remoteBKUpdateCube1.bat文件中。内容为:
schtasks /run /tn “更新***数据” /s 192.168.0.13 /u sqluser /p “****”
- 在kettle中使用shell组件,想使用命令直接调用updatecubemain.exp,结果一直提示找不到目录。后来在linux中,/home/hadoop/.kettle/kettle.properties文件中加入KETTLE_HOME变量(KETTLE_HOME = /pentaho/pentaho/data-integration/),然后将updatecubemain.sh放在KETTLE_HOME对应的路径下。
-
sort rows组件引起的异常
如图,在merge join的两个源端因为都要用到排序,所以就偷懒只用了一个排序组件,结果在运行时,排序后的分组一直是running状态,数据也不会动。在将两个源端做单独排序后,etl恢复正常。如下图
-
kettle中实现取分组后的排序取前n条
在将原powercenter中的etl改造迁移到pentaho平台时,遇到如下需求,将所有订单按日期和游戏分组,然后对每组游戏按订单金额排序取前15条。powercenter中直接使用rank组件实现,kettle中无对应组件,只能通过组合其他组件实现此功能。
- 先使用sort rows 对datekey、gameid升序,rawsum(订单金额)降序排列
- 使用group by 组件,对datekey、gameid进行分组,对每组增加rank序号
- 使用filter rows组件过滤出rank<=15的记录就完成了
第二步中group by组件的配置如下:
-
Pentaho Kettle Solutions
-
将数据文件批量导入hive脚本
在将历史库中的用户表数据导入hive时分成了两步,先将用户数据按天导出成一个个数据文件,然后通过如下脚本自动导入。
一般只要修改两处,i=3286是指开始日期到当前的间隔天数,”$DateKey” = “20111107″指定结束时间。
在sqlserver中求两个日期的时间间隔:
select DATEDIFF(DAY, ’2002-11-08′, ’2011-11-07′)
#!/bin/bash
#该脚本用于循环导入用户表for ((i=3286;i>0;i--));do
DateKey=$(date +%Y%m%d -d ' -'$i' day ');
if [ "$DateKey" = "20111107" ] ;then
break;
fi
echo 正在导入${DateKey}的数据
/hadoop/hive/bin/hive -S -e "LOAD DATA INPATH '/TransferData/Userinfo/${DateKey}.txt' OVERWRITE INTO TABLE userinfo PARTITION (datekey='${DateKey}');"
done
-
kettle中group by组件之前未进行排序导致分组失效
-
powercenter中workflow一直running状态问题
前两天有个报表数据有异常,准备重跑,结果整个任务一直是running状态,跑了一晚上还没跑完。后来仔细查看了日志,发现是在载入目标表的时候,一直未完成。原来是由于在客户端执行完删除语句的时候忘记了commit,在etl重新生成这天数据的时候锁住了,一直完成不了。。。mark一下,以防以后再犯此类低级错误!
-
在sqlserver中实现oracle的CONNECT BY PRIOR
遇到一个需求,需要在sqlserver中实现递归查询,也就是实现oracle中的CONNECT BY PRIOR 功能。在stackoverflow查到了解决方案,记录下。
The SQL standard way to implement recursive queries, as implemented e.g. by IBM DB2 and SQL Server, is the
WITHclause. See this article for one example of translating aCONNECT BYinto aWITH(technically a recursive CTE) — the example is for DB2 but I believe it will work on SQL Server as well.Edit: apparently the original querant requires a specific example, here’s one from the IBM site whose URL I already gave. Given a table:
CREATE TABLE emp(empid INTEGER NOT NULL PRIMARY KEY, name VARCHAR(10), salary DECIMAL(9, 2), mgrid INTEGER);where
mgridreferences an employee’s manager’sempid, the task is, get the names of everybody who reports directly or indirectly toJoan. In Oracle, that’s a simpleCONNECT:SELECT name FROM emp START WITH name = 'Joan' CONNECT BY PRIOR empid = mgridIn SQL Server, IBM DB2, or PostgreSQL 8.4 (as well as in the SQL standard, for what that’s worth;-), the perfectly equivalent solution is instead a recursive query (more complex syntax, but, actually, even more power and flexibility):
WITH n(empid, name) AS (SELECT empid, name FROM emp WHERE name = 'Joan' UNION ALL SELECT nplus1.empid, nplus1.name FROM emp as nplus1, n WHERE n.empid = nplus1.mgrid) SELECT name FROM nOracle’s
START WITHclause becomes the first nestedSELECT, the base case of the recursion, to beUNIONed with the recursive part which is just anotherSELECT.SQL Server’s specific flavor of
WITHis of course documented on MSDN, which also gives guidelines and limitations for using this keyword, as well as several examples.原文地址:http://stackoverflow.com/questions/959804/simulation-of-connect-by-prior-of-oracle-in-sql-server
另附中文版的一个:
http://www.cnblogs.com/xbf321/archive/2009/04/30/1446833.html








