Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Is it possible to have global variables in Kettle javascripts?

  1. #1
    Join Date
    Oct 2007
    Posts
    4

    Default Is it possible to have global variables in Kettle javascripts?

    Hi everyone,

    Is it possible to have a global variable in a Kettle javascript, e.g. keeping track of the minimum value encountered in a field?

    As I understand it, Kettle runs the javascript for each row - and all the variables are lost after each run. Is there somewhere a value could be stored for the script to retrieve at the next run?

    Best regards,
    Jóan Petur

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    You can have "global variables"... Look at the example in the user-guide or in the FAQ.

    Regards,
    Sven

  3. #3
    Join Date
    Oct 2007
    Posts
    4

    Default

    Hi Sven,

    Thank you for your answer.

    I looked in the Spoon User Guide 3.0 that came with Kettle, but couldn't find anything regarding global variables in javascript I found something about obtaining the previous row, but that is not what I'm after.

    Best regards,
    Jóan Petur

  4. #4
    Join Date
    May 2006
    Posts
    4,882

    Default

    Well... how do you think the values of the previous row are stored?... it's the same principle.

    Regards,
    Sven

  5. #5
    Join Date
    Mar 2009
    Posts
    137

    Default

    I think thats a really intresting question and I don't find anything about this topic either.

    Using a global variable just in the one javascript step would be really intresting to pass information from one row to another, is there a way?

  6. #6
    Join Date
    Apr 2007
    Posts
    2,010

    Default

    you seem to be missing something obvious.

    Define a variable X

    That variable X is then set, simple as that, and it's value is available for all subsequent rows.

    So simply say if value < x then X = value in your javascript code.

    If you meant can you pass values to another javascript step (?) then simply add the value to the stream and read it back in when you need it.

  7. #7
    Join Date
    Mar 2009
    Posts
    137

    Default

    Thanks codek, I thought I tried it but

    var test = 0;

    at the beginning does not really help to test

    Thanks again!

  8. #8
    Join Date
    Apr 2007
    Posts
    2,010

    Default

    lol, yes we've all done that

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.