Six Stars

Data Mapper - Distinct Child Element on flat file source not working?

Could someone help me figure out why the Distinct Child Element property on a Simple Loop is not working in this situation..

 

I have a simple flat file that has IDs and Zipcodes.

id;zipcode
1;44100
1;44200
2;69002
2;56410
2;56100

 

I want the output to look like:

<Root>
	<Record>
		<id>1</id>
		<Zips>
			<Zipcode>44100</Zipcode>
			<Zipcode>44200</Zipcode>
		</Zips>
	</Record>
	<Record>
		<id>2</id>
		<Zips>
			<Zipcode>69002</Zipcode>
			<Zipcode>56410</Zipcode>
			<Zipcode>56100</Zipcode>
		</Zips>
	</Record>
</Root>

However when I use the Distinct Child Element and set it to "id", it only brings back the first ID, number 1.  ID #2 is ignored.  The result is:

<Root>
  <Record>
    <id>1</id>
    <Zips>
      <Zipcode>44100</Zipcode>
      <Zipcode>44200</Zipcode>
    </Zips>
  </Record>
</Root>

Screenshot of the mapping:

image.png

 

It is odd because this Distinct Child Element component works with an XML input, as can be seen in the example given on this post.  But why did the user need to create a 2nd map just to filter get the unique list and why couldn't they have done it in just 1 mapping?  Instead they had to create a 2nd mapping just for the Distinct Child Element setting.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Eight Stars

Re: Data Mapper - Distinct Child Element on flat file source not working?

Hi,

 

I found that out here:

https://jira.talendforge.org/browse/TDM-4476
https://jira.talendforge.org/browse/TDM-562

 

If you input is Map, yes you have to use prefix Map. When it is XML, you can omit it.

 

Eric

5 REPLIES
Six Stars

Re: Data Mapper - Distinct Child Element on flat file source not working?

Is it possible this could be a bug?  I didn't find anything specifically related in the report issues. This ticket here might be but the thing I'm trying to do a distinct on is not looping itself, it is within a loop.

Eight Stars

Re: Data Mapper - Distinct Child Element on flat file source not working?

Hi,

 

Could you try with:

Capture.PNG

Six Stars

Re: Data Mapper - Distinct Child Element on flat file source not working?

That looks like it worked!!  How did you know to use "Flat:"?   Also do you know if I have to use something else if my input is a "Map" (dataflow from within Talend) instead of an input of a CSV?  I will be testing this out with Map input soon.

Eight Stars

Re: Data Mapper - Distinct Child Element on flat file source not working?

Hi,

 

I found that out here:

https://jira.talendforge.org/browse/TDM-4476
https://jira.talendforge.org/browse/TDM-562

 

If you input is Map, yes you have to use prefix Map. When it is XML, you can omit it.

 

Eric

Six Stars

Re: Data Mapper - Distinct Child Element on flat file source not working?

You are f*kin brilliant.  Thank you very much.