Skip to Content
avatar image
Former Member

Need UDF to concatenate using delimiter @

Hi All,

I have below requirement

source structure

Node ( 0 to unbound)

  Field (0 to 1)            this field my come max 6 times i need to concatenate these values using delimiter @ and need to put into single target field.

guys if any one have idea please share it to me.

Thanks in advance.

Regards,

AS

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 22, 2015 at 02:34 PM

    Hi AS,

    You can use below UDF.

    Execution type: All values of context.

    public void concat(String[] input, ResultList result, Container container) throws StreamTransformationException {
      String output = "";
      boolean first = true;
      for (int i = 0; i < input.length; i++) {
      if (first) {
      output = output + input[i];
      first = false;
      } else {
      output = output + "@" + input[i];
      }
      }
      result.addValue(output);
      }
    

    Mapping is like below:

    Field------->removeContexts------>UDF------>Target

    Regards,

    Praveen.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 22, 2015 at 03:23 PM

    try to use text -> concat function multiple times to achieve the same result.

    Add comment
    10|10000 characters needed characters exceeded