Hi Mohan,
You can use below code, after D field and E field use mapWithDefault and give the value as "NA" then if any context missing then you will get NA in the result. instead of using + operators you can use StringBuilder to append the strings in the UDF.
public void mapResult(String[] aField, String[] bField, String[] cField, String[] dField, String[] eField, String[] fField, ResultList result, Container container) throws StreamTransformationException { StringBuilder sb = new StringBuilder(); sb.append("A value is:").append(aField[0]).append("\n"); sb.append("B value is:").append(bField[0]).append("\n"); sb.append("C value is:").append(cField[0]).append("\n").append("\n"); for (int i = 0; i < dField.length; i++) { sb.append("D value is:").append(dField[i]).append("\n"); sb.append("E value is:").append(eField[i]).append("\n"); String fValue = (i == 0) ? fField[0] : "NA"; sb.append("F value is:").append(fValue).append("\n"); sb.append("\n"); } sb.setLength(sb.length() - 1); result.addValue(sb.toString()); }
Regards,
Praveen.