【问题标题】:Passing SQL query as a Parameter in Pentaho?在 Pentaho 中将 SQL 查询作为参数传递?
【发布时间】:2017-10-12 12:17:57
【问题描述】:

有一个 Pentaho 步骤我被卡住了。这是我在 Pentaho 步骤之一中的 SQL 查询:

select t.val_1  as Contract, 
       t.val_2  as Service,
       t.val_3  as Calender,
       t.val_4  as MSPProvider,
       t.val_5  as MSPCustomer,
       t.val_6  as ObjectName,
       t.val_7  as EventID,
         to_timestamp(t.val_8,'MM-DD-YYYY HH:MI:SS PM')  as Startdate,
         to_timestamp(t.val_9,'MM-DD-YYYY HH:MI:SS PM') as Startkeydate,
         to_timestamp(t.val_10,'MM-DD-YYYY HH:MI:SS PM') as Enddate,
        to_timestamp(t.val_11,'MM-DD-YYYY HH:MI:SS PM') as Endkeydate,
       t.val_12 as Duration,
       t.val_13 as DurationMod,
       t.val_14 as Suspend,
       t.val_15 as SuspendExternal,
       t.val_16 as Excluded,
       t.val_17 as Target,
       t.val_18 as TargetUnit,
       t.val_19 as Relation,
       t.val_20 as Violated,
       t.val_21 as CalculationType,
       t.val_22 as calculationversion,
       t.val_23 as Category,
       'sec' as ValueUnit,
       t.val_24 as TicketUnit,
       t.val_25 as Severity,
       t.val_26 as Impact,
       t.val_27 as ExclusionID,
       t.val_28 as OriginatorID,
      t.val_25 as SeverityID,
       t.val_29 as ReOpened,
       t.create_date as CreateDate,
       t.modify_date as ModifyDate

from t_slalom_outputs t 

where t.is_active = 1
      and t.table_name = 'TICKET'
    and t.val_4 = '${MSP_PROVIDER}'

      and t.modify_date > (SELECT sp_timestamp FROM public.msp_startingpoints where sp_name = 'etl_export_result_slalom')

modify_date > 之后的查询是从 Postgres 数据库中选择数据,其余的查询是从 Oracle 服务器获取数据。 我应该如何划分两者?

一个是从 Oracle 中的表 t_slalom_outputs 中获取数据,另一个是从 Postgres 表 msp_startingpoints 中获取数据。 修改后的date >(Postgres 查询)

有什么方法可以将 Postgres 查询作为参数值传递给整个查询?

【问题讨论】:

  • 如果我明白你只关心修改日期大于某个值的 ORACLE.t_slalom_outputs 的行。限制值不依赖于 ORACLE 数据,但您不能对其进行硬编码,因为它取自 POSTGRES 数据库。

标签: pentaho etl kettle data-integration pentaho-data-integration


【解决方案1】:

使用输入表从 Postges 数据库中获取 msp_startingpoints。然后将结果放到 Input table 中,并使用您的查询,除了 t.modify_date > (SELECT ...) 已被 t.modify_date > ? 替换,指定 Insert data from step 作为第一步。

就是这样。

神奇之处在于问号被传入步骤中的值替换。在您的情况下,您有一列和一行,但您可能有更多列(注意列的顺序)并且您不止一行(注意结果中行的顺序)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-02
    • 2020-11-24
    • 1970-01-01
    • 1970-01-01
    • 2019-09-11
    • 2021-09-21
    • 1970-01-01
    • 2020-03-29
    相关资源
    最近更新 更多