Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Drop columns dynamically

  1. #1
    Join Date
    Aug 2008
    Posts
    27

    Default Drop columns dynamically

    I am attempting to use Javascript to drop columns from outbound data depending on the column name. I am using the "removeValueMeta" method of the rowMeta object, but it doesn't seem to work. I am obviously missing something. Sample code is:

    var
    rowMeta = getInputRowMeta();

    var
    columnName;

    for
    ( i=rowMeta.size()-1; i >= 0; i--)
    {
    var valueMeta = rowMeta.getValueMeta(i);
    columnName = valueMeta.getName();
    if ( columnName == "CUST_ID" || substr( columnName,0,4 ) == "ROW_" )
    rowMeta.removeValueMeta(i);
    }


    All inbound columns, including the ones I am attempting to drop, are appearing on the outbound side. Any suggestions would be appreciated.

    TIA
    Gene


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

    Default

    I don't think that is intended to work (dynamic meta-data is not really supported)... in the 3.0 model that will even give you more problems.

    Regards,
    Sven

  3. #3

    Default

    Hi,

    I have same problem. I now successfully drop a column / header from output rowset using getOutputRowMeta().removeValueMeta(index).

    For example using getOutputRowMeta().removeValueMeta(0) will remove first column from output rows.

    The problem is, the actual data from the previous first column remain. How do I achieve a complete column drop dynamically in Javascript step ?

    Thanks,

    Feris

  4. #4

    Question RowDataUtil.removeItems

    I'm trying to remove items dinamycally using these script

    Code:
    java
    
    newRow = createRowCopy(getOutputRowMeta().size());
    var hasil = org.pentaho.di.core.row.RowDataUtil.removeItems(newRow, 0);
    var rowIndex = getInputRowMeta().size();
    
    newRow[rowIndex++] = "Y";
    
    putRow(newRow);
    
    var Keep = "";
    But found that newRow is treated as an object instead of objec[]. Here are the errors :

    Code:
    2009/10/25 18:53:05 - Modified Java Script Value.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : Unexpected error : 
    2009/10/25 18:53:05 - Modified Java Script Value.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : org.pentaho.di.core.exception.KettleValueException: 
    2009/10/25 18:53:05 - Modified Java Script Value.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : Javascript error: 
    2009/10/25 18:53:05 - Modified Java Script Value.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : Can't find method org.pentaho.di.core.row.RowDataUtil.removeItems([Ljava.lang.Object;,number). (script#4)
    Any workaround on this ?

    Thanks,

    Feris

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

    Default

    How do I achieve a complete column drop dynamically in Javascript step ?
    As Sven already mentioned: you can't.

    No work-around, nothing we would want to implement anyway. End of story.

  6. #6

    Default

    Is there some type of programmatic way to create the values that could be used by a Select Values or equivalent step?

    Instead of 'dropping' data, maybe only select the data you want to continue forward down the stream.

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

    Default

    Obviously, anything is possible in Java.
    You can for example dynamically generate the transformation to execute.

    See the API sample on the wiki.

  8. #8

    Default

    Hi Matt,

    Quote Originally Posted by MattCasters View Post
    As Sven already mentioned: you can't.

    No work-around, nothing we would want to implement anyway. End of story.
    Thanks for the confirmation. In that case, I will try to manipulate the Environment Variable to change the SQL Queries.

    Regards,

    Feris

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.