Hitachi Vantara Pentaho Community Forums
Results 1 to 10 of 10

Thread: Javascript functions

  1. #1
    Join Date
    Sep 2008
    Posts
    26

    Default Javascript functions

    I had a look through the FAQ's the document Wiki's and the documentation about compatibility mode, but there does not seem to be a document on the functions available in the modified JavaScript step.

    Is there a document available that outlines the variables specific to Spoon and what their use is?

    As an example "putRow", "newRow", etc. is used, but their parameters are never really discussed.

    Thanks
    Des

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

    Default

    If you're not working with a transformation from pre-3.0, I would use compatibility off.

    Compatibility on is the "old style" of working where each basic type in a "column" of a row was wrapped in a Value object (which also contained its metadata, ...).

    v3.0 was a rewrite which moved the meta-data out of each row, and didn't wrap the basic types anymore. The examples you find on the wiki and anywhere else would normally be converted to the "compatibility off" way.

    Regards,
    Sven

  3. #3
    Join Date
    Sep 2008
    Posts
    26

    Default

    Sven

    Thanks for the reply. That cleared up the compatibility issue, but I still need to get a reference for the functions that are available. I read that JavaScript is based on Rhino, so I had a look there, but that is more generic JS.

    Is there a guide to the functions specific to Kettle? examples of this is newRow, createRowCopy(), etc. These functions are not really defined anywhere or discussed. I have searched the wiki and even looked in the source code to get a bit of an idea.

    Is there a list of the functions that JS modified will recognise? A quick parameter list reference or something similar.

    Thanks
    Des

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

    Default

    Right click on them in the tree on the left...

  5. #5
    Join Date
    Sep 2008
    Posts
    26

    Default

    Matt

    Thanks for the response. Did that with the functions that are there. There are however a few functions not in the tree list. Just wondering where these are documented.

    Initially I thought these were the only functions supported, but working throught the examples I came across a few functions that are not in the tree view such as "createRowCopy", "getOutputRowMeta", "getInputRowMeta", "putRow", "newRow", etc. These appear to be Kettle specific functions and just looking for documentation on them

    Thanks
    Des

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

    Default

    They have a specific use-case that is documented on the wiki. Beyond that specific use-case, I would rather discourage people from actually using those functions.
    Most things that these functions were invented for can be done without JavaScript these days anyway.

  7. #7
    Join Date
    Feb 2008
    Posts
    216

    Default Trying to create rows

    Quote Originally Posted by MattCasters View Post
    They have a specific use-case that is documented on the wiki. Beyond that specific use-case, I would rather discourage people from actually using those functions.
    Most things that these functions were invented for can be done without JavaScript these days anyway.
    Hi Matt -
    Since these functions are not recommended to be used and you recommend native java script instead... I'm definitely no java script expert and I was using an example that was provided in the samples directory to create new rows. This example still uses the commands mentioned in the prior post...

    newRow = createRowCopy(getOutputRowMeta().size());
    var rowIndex = getInputRowMeta().size();

    I'm trying to understand how the sample works so I can make it work for the transformation I'm currently building. If you are steering us away from using these commands, can you recommend a standard java script command that I should be looking at? Or point me to the wiki that explains this example?

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

    Default

    I'm sorry, you misunderstood. The use-cases are these days almost all solved with separate steps.
    The most common need back then was for the "Split Field to rows" but these days we even have "Clone Rows" etc in the step portfolio.
    In 3.2.0-M1 we added the "Analytics" step as well that allows you to retrieve information from previous (-1, ..., -N) rows. (and more)

    Solving those complex problems with dedicated steps is obviously better in the long run. Less code for the ETL developer to maintain is always better but the performance is also a lot better.

    Take care,
    Matt

  9. #9

    Default

    Dear Matt,

    The Analytics is a complete new version of PDI... which may not be recommended for major use i guess...

    So we should actually document these special method.. by going looking at the implimented code for the corresponding funtion..


    regards

    sarat

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

    Default

    You are obviously free to do so, be my guest.

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.