1

I have a column that is something like this

A B
Value1 Some Value
null Some Value
null Some Value
Value2 Some Value
Value3 Some Value
null Some Value
null Some Value

and i want

A B
Value1 Some Value
Value1 Some Value
Value1 Some Value
Value2 Some Value
Value3 Some Value
Value3 Some Value
Value3 Some Value

i have used tjava_row but have encountered certain error. i have used the code given below, or should i go for python(ffill) or pyspark for designing the elt job:

if (row2.A==null) {
 row2.A = row1.A
} else {
 row2.A=row2.A; 
Wmm
  • 139
  • 5
  • I think the answer to your question can be found here https://stackoverflow.com/questions/36343482/fill-in-null-with-previously-known-good-value-with-pyspark – seghair tarek Mar 14 '22 at 08:22
  • You can do this using java, python, excel, or whatever you want. Please only ask question about programing issues. Currently your question is opinion based. – Steven Mar 14 '22 at 11:52

1 Answers1

0

With Talend, you can use a tMap with intern variables to use previous values. You'll need three variables (from the central tab in your tMap) :

  • current : row1.yourValue // cache your input data for current line

  • previous : Relational.ISNULL(Var.current)?Var.previous:Var.current //if current line is null, keep the previous one. Otherwise replace 'previous' with current line.

  • getPreviousIfNull : Relational.ISNULL(row1.yourValue)?Var.previous:Var.current

    //if your input data is null : get the previous one. Otherwise get the current one.

row1.yourValue is your input data.

Then you extract Var.getPreviousIfNull to your output.

enter image description here

Corentin
  • 2,442
  • 1
  • 17
  • 28
  • @Corentin-Thank you for your reply. For current value i am using Var.var1(row1.A), Previous: Relational.ISNULL(Var.var2)?Var.var1:Var.var2 and for getPreviousIfNull Relational.ISNULL(Var.var3)?Var.var2:Var.var3. Please correct me where i am wrong, As i am only getting the Value1 in the entire column. – Wmm Mar 14 '22 at 10:51
  • i've added a screenshot – Corentin Mar 14 '22 at 11:21