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

巧了我就是萌 提交于 2019-12-11 15:52:40

问题


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?


回答1:


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.

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



来源:https://stackoverflow.com/questions/57996478/comparison-between-current-row-previous-row-and-next-row-in-talend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!