Hitachi Vantara Pentaho Community Forums
Results 1 to 9 of 9

Thread: Eval step

  1. #1

    Default Eval step


    I created a data grid step with some fields that contain things like myfile${FILE_NAME}.txt
    Which is the easiest step that could make the whole table be eval'ed, so it reads every field and converts it?

    Currently I am using calculator, with the variable substitution operation, but:
    - I did not find the way to just replacing the field, so I need to create extra calculated field, and then an extra step to move the contents from the new column to the former.
    - I need to define each and every expected field, not an automatical eval

    It could be nice if data grid had autoresolved value fields, but if not, an Eval step would be really nice, simply resolving all variables present in the middle of a value

    Is there any more obvious thing or missing step?


  2. #2
    Join Date
    Jun 2012


    You shouldn't add variable notation to field values just to struggle for a clean replacement strategy.
    You can do it in one fell swoop using a "Replace in String" step.
    So long, and thanks for all the fish.

  3. #3


    I tried but I can't.

    Replace String does not provide me an eval logic. I need to specifically check for a substring and specifically indicate the output. I don't want to say if you find "${myVar}" please substitute it for my myVar_Value. Imagine any var can be used, I'd need to define that pattern in the string for every possible var that can show up.

  4. #4
    Join Date
    Jun 2012


    Oh, I didn't suggest to use Replace-In-String to substitute variables, I had an unconditional text insertion in mind.
    Multiple conditional modifications can be made using Java expressions, for instance.
    If you can describe the conditions we might find a Kettle compatible way to implement them.
    So long, and thanks for all the fish.

  5. #5
    Join Date
    Nov 2008


    Consider Javascript step. You have a getVariable function available. It should be not daunting to analyze the content of a field to extract the text between braces and pass it to the function to evaluate.
    Of course, always bear in mind that variables must be set in a previous transformation.
    Andrea Torre
    twitter: @andtorg

    join the community on ##pentaho - a freenode irc channel

  6. #6


    Thanks guys! I think I'll keep using the calculator given there is no trivial strategy using simple out-of-the-box steps.

    If only calculator had a flag for replacing instead of adding fields...

  7. #7


    At the end I'm checking the JS Execute for each Row script to do eval

    I have a doubt: I read that

    This was a possibility in version 2 and caused some problems in transformations here and there in the steps after the JavaScript steps. Instead of modifying fields in-place, create new fields using the table at the bottom of the Modified Javascript transformation. Then assign values to them directly in the script, as if they were variables

    Supposing I want to program it forward compatible, how can I dynamically define a "foreach field replace with eval(value)" if now I need to manually assign each field and var?


  8. #8


    Could anyone shed some light about best practices for this?

  9. #9


    Summing up, I'd like to know how the following would be performed without compatibility mode on:

    for (var i=0;i<getInputRowMeta().size();i++){

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.