Dan Monunu
Dan Monunu

Reputation: 1

Comparison between current row, previous row and next row in Talend

I want to know if my value is included in an interval consisting of the previous row and the next row. How to do it in Talend?

I tried a tMemorizeRow function where I save 3 lines each time, but encountered a java.lang.NullPointerException exception as when I am on the first line it does not know the next row I saved.

What am I missing?

Upvotes: 0

Views: 1393

Answers (1)

Corentin
Corentin

Reputation: 2552

You can try this : add a column "sequence" with value as Numeric.sequence("s1",1,1)to your data : this way you'll know this exact order between rows in your flow (you can do it in a tMap). Redirect the tMap to a tHashOutput component (if you can't find in the palette, add it through Project Parameters>Designer>Palette>Technique , this component is hidden by default).

Then you'll need an other subjob, with 3 tHashInput : one for your main flow, and the two others as lookup : then you'll be able to join rows with previous and following one , thanks to your 'sequence' field.

enter image description here

enter image description here

Then in tMap_2 you'll be able to compare values from mainFlow with Previous and Next flows.

Upvotes: 1

Related Questions