Generating and configuring an AgConcat expression - 7.3

Talend Data Mapper User Guide

Version
7.3
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2023-01-05

Talend Data Mapper can automatically generate an AgConcat expression to deal with incompatible loops.

About this task

This example uses the following XML sample as input:
<root>
	<loopA>
		<A>a1</A>
		<loopB>
			<B>b11</B>
		</loopB>
		<loopB>
			<B>b12</B>
		</loopB>
		<loopC>
			<C>c11</C>
		</loopC>
		<loopC>
			<C>c12</C>
		</loopC>
	</loopA>
	<loopA>
		<A>a2</A>
		<loopB>
			<B>b21</B>
		</loopB>
		<loopB>
			<B>b22</B>
		</loopB>
		<loopC>
			<C>c21</C>
		</loopC>
		<loopC>
			<C>c22</C>
		</loopC>
	</loopA>
</root>
The XML output structure is defined as follows:
root
	row (0:*)
		A
		B
		C1
		C2

Procedure

  1. Create a map and add your input and output structure.

    Example

  2. Drag the input A element to the output A element.
    A looping expression is automatically created on the output row element.
  3. Drag the input B element to the output B element.
    This action creates a conflict, the looping context of the input B element is not compatible with the current output looping context.
  4. Select Generate AgConcat value expression on out$/root/row/B and click OK.
    An AgConcat function is automatically added to the output B element.
  5. Drag the input C element to the output C1 element, then select Generate AgConcat value expression on out$/root/row/C1 and click OK.
  6. Drop a SingleIndex function on the Filter argument of the AgConcat function.
    This allows you to specify that the output C1 element should only return the first value of the input C element.
  7. Drag the input C element to the output C2 element, then select Generate AgConcat value expression on out$/root/row/C2 and click OK
    Because the sibling C1 element contains a filter, a matching filter is automatically added to C2 so that it only returns the second value of the input C element.

Results

The map is configured, you can use the Test Run option to see the result. In this example, it should look like this:
<root>
  <row>
    <A>a1</A>
    <B>b11b12</B>
    <C1>c11</C1>
    <C2>c12</C2>
  </row>
  <row>
    <A>a2</A>
    <B>b21b22</B>
    <C1>c21</C1>
    <C2>c22</C2>
  </row>
</root>