Hitachi Vantara Pentaho Community Forums
Results 1 to 12 of 12

Thread: Appending Job parameters to rows in Transformation

  1. #1

    Default Appending Job parameters to rows in Transformation

    Hi All,

    I've attached a picture to illustrate a challenge I'm working through. I have some constants that I pass to a job as command line params (site_id for example). I tried adding ${site_id} to the table output step, but it doesn't seem to provide variable substitution.

    Anyone have a suggestion about the best way to accomplish this? I tried the add constants step (that inserted the literal text) as shown.

    Thanks,

    David
    Attached Images Attached Images  

  2. #2
    Join Date
    Jul 2011
    Posts
    4

    Default

    I've got the same problem. please..... HELP !!!!!

  3. #3
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    Have you defined your variables in a previous transformation?

    I think (but not 100% sure) that you need to define variables in a transformation using "Set Variables" step, then in the next transformation use those variables or add step "Get Variables".
    Obviuosly you need to wrap those 2 transformations in one job.

    Mick

  4. #4

    Default

    These are parameters passed on the command line, with Param:key=value... There is only one transformation in this job, so I don't have the issue of multiple transformations handing off values one to another. In steps that permit variable substitution - the params make it to the transformation and steps just fine... for example, I use ${DB_USERNAME} for the table output step (connection definition) and that's all good. The challenge is with the values in the db insert. it set variable is what I need to map param:site_id=20 to get 20 into the database, I must have done something wrong, I think I tried that approach.

    DB

  5. #5
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Did you try putting the Get Variables step instead of your Add Constants step?

  6. #6

    Default

    I did try both the get and set variables, and the add constants. I'm looking at this link now:

    http://wiki.pentaho.com/display/EAI/...rameter+values

    I think that's probably what I need.

    I'll confirm.

    DB

  7. #7
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    The get Variables step inline in your process should do what you want.

  8. #8

    Default

    Thanks gutlez... that works. I thought that I had done this before. It turns out that I left out some params from when testing. My process takes the form of launcher.sh <config file> in the config file I put key value pairs and in the launcher I specify the variables. I need to add better error checking in the launcher to error if params don't match.

  9. #9
    Join Date
    Jul 2011
    Posts
    4

    Default

    I have to add a costant value passed in command line, into a cvs file, not into a db Table.

    Name:  GiocateVincenti.jpg
Views: 44
Size:  7.2 KB


    So in the first step, i select, for example, N row from the table, each of which consists of X fields.
    In the second step i need to append to each row a value passed like parameter from the command line.
    In the third step i have to produce a csv file whit X+1 Fields

    The problem is in the second step.... because i can't specify tha parameter value in this step.

    Can you suggest me a possible solution???
    Thank you very much

  10. #10

    Default

    Here is what I ended up with... hope it helps...

    Name:  Screenshot1.png
Views: 38
Size:  16.5 KB

    Name:  Screenshot2.jpg
Views: 39
Size:  9.0 KB

    I pass SITE_ID... as params on the command line (and they end up stored properly in the database).

    DB

  11. #11
    Join Date
    Jul 2011
    Posts
    4

    Default

    Quote Originally Posted by stefanomos View Post
    I have to add a costant value passed in command line, into a cvs file, not into a db Table.

    Name:  GiocateVincenti.jpg
Views: 44
Size:  7.2 KB


    So in the first step, i select, for example, N row from the table, each of which consists of X fields.
    In the second step i need to append to each row a value passed like parameter from the command line.
    In the third step i have to produce a csv file whit X+1 Fields

    The problem is in the second step.... because i can't specify tha parameter value in this step.

    Can you suggest me a possible solution???
    Thank you very much
    if it could be useful, i found a possible solution:

    Name:  GiocateVincenti_OK.jpg
Views: 31
Size:  8.7 KB

    where
    - in "Add Costant Value"step, add a new field called Y without value
    - in "Get Variables" step, define and set a variable X with the parameter value passed by the command line
    - in "Modified Java Script" step, write the command Y.setValue(X);

    it works well.
    Bye
    Stefano.

  12. #12
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Stefano,

    That will not scale well.
    You can get rid of the Add Constant Value and the Modified Java Script Value steps, and just use the Get Variables step, taking your parameter directly into Y.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.