Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Using varible substitution in custom plugins

  1. #1
    Join Date
    Aug 2008
    Posts
    7

    Default Using varible substitution in custom plugins

    I am trying to build a custom plugin and want some of the fields to be able to use variable substitution. I created TextVar fields in my plugin but the variables are not being set at runtime and they don't show up when displaying the environment variables. I tried looking at other transforms that use variable substitution but I can't find anything that I am not doing. Is there some step/setting that I am missing? Thanks.

  2. #2
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    You need to use a VariableSpace to replace the variable at runtime.
    TransMeta, DatabaseMeta, JobMeta, etc all implement VariableSpace.

  3. #3
    Join Date
    Aug 2008
    Posts
    7

    Default

    I am not sure exactly what you mean, could you point me to an example in the kettle code base? Thanks.

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

    Default

    Search for the method "environmentSubstitute" in the source code.

    Regards,
    Sven

  5. #5
    Join Date
    Aug 2008
    Posts
    7

    Default

    I did a search of the code base and I found "environmentSubstitute" in a bunch of places but I also found that many transforms don't have references to it and still work with variable substitution. For example, FieldSplitter doesn't seem to use "environmentSubstitute" but the "Field to split" field works with variable substitution. I have been digging around for the past few hours and can't figure it out. My transforms seem to be implemented in a similar manner but variables are not substitutable and using spoon to show the env variables doesn't show anything. Does anyone know what I am missing? I can create a simple example if that helps. Thanks.

  6. #6
    Join Date
    Aug 2008
    Posts
    7

    Default

    Ok, I think I finally figured it out. So it turns out the Field Splitter step doesn't really do variable substitution, even though the Spoon gui allows you to set the variables. It seems like Spoon just looks for ${...} entries in the transformation and then looks at the steps Meta class for the private variable that would be set by the ${...} and if it finds a private variable it displays the ${...} in the environment variables list. My variables weren't showing up originally because by convention I call all my private variables _foo (leading underscore) and that seems to have prevented spoon from displaying them. To actually get variable substitution to work and have Spoon display my variables, I had to change the names of my private variables and use "environmentSubstitute" in my processRow code.

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.