Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: In Spoon, setting field 1 to match value in field 2, field 1 is null

  1. #1
    Join Date
    Sep 2010
    Posts
    22

    Default In Spoon, setting field 1 to match value in field 2, field 1 is null

    Hello,

    I'm pulling XML data into Spoon and want to copy the value from one field (say called "Category") into another field called "Child" only if "Child" has no data (null).

    So the logic is: For each row, if "Child" is empty, copy the value from "Category" into "Child".

    What's the best way to do this using the function blocks provided in Spoon (trying to avoid custom code). Thanks in advance!

  2. #2
    Join Date
    Nov 2008
    Posts
    143

    Default

    Did you try filter rows?

  3. #3
    Join Date
    Sep 2010
    Posts
    22

    Default

    Thanks for your response renatopb. Well, I added a filter rows step that compare the "category" field with the "child" field. If the data is true, it then goes to an "Append Streams" step. The false data goes to a "Stream lookup" step which is supposed to the "child" field equal to the value stored in the "category" field. This data then joins the data true in the "Append Streams" step. I imagine that both streams get re-integrated together for further processing? Does that make sense? Thanks again.

  4. #4
    Join Date
    Nov 2008
    Posts
    143

    Default

    Hey Joe,

    You don't have to use Append Streams for that, as it keeps an order of evaluation. First one stream, then the other. I believe you don't need that, do you?
    In case you don't, just use any step to join them by sending both hops to the same target step.

    Anyways, I just realized that you're trying to get some child data when child is available and then do some more processing in all rows.
    If that's true, then you don't need the Filter rows step. Just use Stream lookup and it will have the same efect, but without the need to join the streams later. Got it?

    Your actual scenario
    Code:
    [full-stream]                        [child data stream]
          |                                     |
          v                                     v
    [Has child? (filter rows)] --> [Get child info (stream lookup)]
          |                             |
          v                             /
    [append stream]<-------------------/
          |
          v
     [continue...]
    All you need is:
    Code:
                        [child data stream]
                                |
                                v
     [full-stream] --> [Get child info (stream lookup)] --> [continue...]

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.