Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to modify a target step's row meta structure from the code of my UDJC step?

  1. #1
    Join Date
    Apr 2017
    Posts
    3

    Default How to modify a target step's row meta structure from the code of my UDJC step?

    Hi there,

    How can I change the row meta structure of a target step from the code of a custom UDJC step?

    There is a hop between my UDJC step (which is the source step) and the target step (which is a "Text file output" type of step).

    In my UDJC code, I have retrieved the target step meta like this:

    StepMeta myTargetStepMeta = getTransMeta().findStep(getParameter("MY_TARGET_STEPNAME"));

    In the beginning of the processRow() method's code in my UDJC step, I am constructing a new row meta structure by calling this "addField" method (see below) a few times inside the code of an "if (first){ ... }" block. So, it is only building the new row meta structure during the first iteration of the UDJC's processRow() method. Now, how would I assign the newly generated row meta structure (RowMetaInterface object) to my target step (myTargetStepMeta)?

    The target step is currently receiving an input stream with 2 fields.

    From the code of my UDJC step, I would like to remove the 2 input fields from the stream that is going to the target step by default and then I would like to add 3 new fields to that target step. So, when viewing the data in the target step after the execution of the transformation, I would be seeing the names & values for the 3 new fields instead of seeing the 2 field names that are coming from previous steps.

    private void addField(RowMetaInterface row, String fieldName, int type, int length, int precision) throws KettleStepException {
    try {
    ValueMetaInterface value = ValueMetaFactory.createValueMeta( fieldName, type, length, precision );
    value.setOrigin( myTargetStepMeta.getName() );
    row.addValueMeta( value );
    }
    }

    Thanks,
    Paulo
    Last edited by plima; 11-22-2017 at 11:50 AM.

  2. #2
    Join Date
    Apr 2017
    Posts
    3

    Default

    One interesting thing here is that I can see the correct data (my new field names and values) when opening up the text file that is being generated by the target step (which is a "Text file output" step). However, I can't see my new field names when highlighting the target step (the text file output step) and taking a look at the "Preview data" tab in Spoon. When doing that, I can still see the 2 field names that are coming from previous steps. Instead of seeing the 2 old field names, I was expecting to get my new 3 field names displaying under that tab in Spoon. The new 3 field values are properly being displayed under that tab though....the problem seems to be happening only with the row meta data as the 2 old field names are still being displayed under the "Preview data" tab in Spoon, but the values are new....
    Last edited by plima; 11-22-2017 at 12:20 PM.

  3. #3
    Join Date
    May 2016
    Posts
    282

    Default

    Spoon has a cache, to see the new fields try clearing the cache: Tools -> Database -> Clear Cache
    Regards
    OS: Ubuntu 16.04 64 bits
    Java: Openjdk 1.8.0_131
    Pentaho 6.1 CE

  4. #4
    Join Date
    Apr 2017
    Posts
    3

    Default

    I don't deal with any Database connections in this transformation. But anyways, I did clear the cache by going to Tools -> Database -> Clear Cache and that didn't make any difference. Any other ideas?

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.