经历过的,和正在经历的。。。
  • 在Modified Java Script Value组件中修改字段的值

    2012-01-14

    在compatibility mode(兼容模式)时,使用如下方式:

    field1.setValue(100);
    在非兼容模式时,需要使用定义一个新变量来完成
    注意:在新定义的变量中,如果有精度要求的,必须要明确指定,
    如果未指定,在目标表中的数据,小数部分将全为0。
     
    Author:jason | Categories:ETL | Tags:
  • kettle闪退问题

    2012-01-10

    问题:在执行一个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

    Author:jason | Categories:ETL | Tags:
  • 实现远程调用更新cognos中的模型文件

    2012-01-09

    需求:在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,脚本自动生成。

    遇到的几个问题:

    1. 在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
    2. 在远程登录Windows服务器之后,直接执行需要更新的批处理文件无效,其中包含了一些cognos命令。需要做个中转,先在Windows服务器上建立一个任务计划,通过任务计划来调用此脚本。此处是将调用任务计划的脚本写在了remoteBKUpdateCube1.bat文件中。内容为:
      schtasks /run /tn “更新***数据” /s 192.168.0.13 /u sqluser /p “****”
    Author:jason | Categories:ETL | Tags:
  • sort rows组件引起的异常

    2011-12-21

     

    如图,在merge join的两个源端因为都要用到排序,所以就偷懒只用了一个排序组件,结果在运行时,排序后的分组一直是running状态,数据也不会动。在将两个源端做单独排序后,etl恢复正常。如下图

     

     

     

     

     

     

    Author:jason | Categories:ETL | Tags:
  • kettle中实现取分组后的排序取前n条

    2011-12-20

    在将原powercenter中的etl改造迁移到pentaho平台时,遇到如下需求,将所有订单按日期和游戏分组,然后对每组游戏按订单金额排序取前15条。powercenter中直接使用rank组件实现,kettle中无对应组件,只能通过组合其他组件实现此功能。

    1. 先使用sort rows 对datekey、gameid升序,rawsum(订单金额)降序排列
    2. 使用group by 组件,对datekey、gameid进行分组,对每组增加rank序号
    3. 使用filter rows组件过滤出rank<=15的记录就完成了

    第二步中group by组件的配置如下:

    Author:jason | Categories:ETL | Tags:
  • Pentaho Kettle Solutions

    2011-11-28

    献上好书一本,kettle开发必备~

    下载地址

    Author:jason | Categories:ebooks | Tags:
  • 将数据文件批量导入hive脚本

    2011-11-08

    在将历史库中的用户表数据导入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

    Author:jason | Categories:ETL | Tags:
  • kettle中group by组件之前未进行排序导致分组失效

    2011-11-07

    曾经在《Pentaho 3.2 Data Integration Beginner’s Guide》一书中看到过提醒,在分组操作之前,对需要分组的相关字段先进行排序,以免产生异常结果。在改造powercenter中旧的etl任务时,有时候会忘记这一条。今天就遇上了,在对买家分组,进行了look up操作之后,对第二个分组忘记先排序,导致分组功能一直异常,一直得不到想要结果。

    Author:jason | Categories:ETL | Tags:
  • powercenter中workflow一直running状态问题

    2011-10-31

    前两天有个报表数据有异常,准备重跑,结果整个任务一直是running状态,跑了一晚上还没跑完。后来仔细查看了日志,发现是在载入目标表的时候,一直未完成。原来是由于在客户端执行完删除语句的时候忘记了commit,在etl重新生成这天数据的时候锁住了,一直完成不了。。。mark一下,以防以后再犯此类低级错误!

    Author:jason | Categories:ETL | Tags:
  • 在sqlserver中实现oracle的CONNECT BY PRIOR

    2011-10-25

    遇到一个需求,需要在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 WITH clause. See this article for one example of translating a CONNECT BY into a WITH (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 mgrid references an employee’s manager’s empid, the task is, get the names of everybody who reports directly or indirectly to Joan. In Oracle, that’s a simple CONNECT:

    SELECT name  
      FROM emp 
      START WITH name = 'Joan' 
      CONNECT BY PRIOR empid = mgrid 
    

    In 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 n 
    

    Oracle’s START WITH clause becomes the first nested SELECT, the base case of the recursion, to be UNIONed with the recursive part which is just another SELECT.

    SQL Server’s specific flavor of WITH is 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

    Author:jason | Categories:编程杂集 | Tags: