Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Simplest way to add single value to stream of rows

  1. #1
    Join Date
    Aug 2016
    Posts
    290

    Default Simplest way to add single value to stream of rows

    What is the simplest way to add for instance a parameter or any value to each row of a stream?

    I keep making lookup steps like this:

    Name:  temp.png
Views: 893
Size:  7.8 KB

    It creates alot of clutter, specially with the "Add constant" steps which only are used to create a constant "KEY" boolean set to true ('Y') for lookup to do match on.

    Preferably I would just like to link "Get_Files_In_Folder" with "Get_Variables" and "Keep_Selected_Fields". But since two of them are input steps, the first is always discarded.

    Is there an easier way? With less steps, less code, less clutter?

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You can add Get-Variables midstream.
    So long, and thanks for all the fish.

  3. #3

    Default

    I used to add a fake constant to each path that I was joining and set them to the same thing and use a merge join. Then a friend showed me this trick.

    Assuming you are only adding one field to each row, you can use the "Join Rows (cartesian product)" step. One path has all your data. The second path has the one constant item you wish to add (a parameter or whatever). I'll often use a data grid with one row of the item I'm adding in. Bring them together with the "Join Rows (cartesian product)". You don't need to set any join criteria ("The condition") in the step.

    Hope that helps!
    Check out my free Pentaho PDI (Kettle) Getting Started Mini Course. You get a short lesson every day for four days, delivered to your email inbox.

  4. #4
    Join Date
    Aug 2016
    Posts
    290

    Default

    Quote Originally Posted by marabu View Post
    You can add Get-Variables midstream.
    Really? GetVariables-step generates rows, usually steps that generate rows does not work well mid-stream. I'm pretty sure I have tested this to not work, but have to confirm it later.

  5. #5
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Quote Originally Posted by Sparkles View Post
    GetVariables-step generates rows?
    Not exactly.
    It adds fields to a row - with a twist: If there's no row coming in, it makes one up to make ends meet.
    So long, and thanks for all the fish.

  6. #6
    Join Date
    Aug 2016
    Posts
    290

    Default

    Thanks! I really like the suggestions made here, both the 'Get Variables' and the 'Join Rows (cartesian product)'. Cartesian product has an added bonus of also working with empty streams! But as mentioned, be warned, it only works for 0-1 rows from each stream, as it results in a multiplication of both incoming streams.

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.