Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
mayo
Contributor III
Contributor III

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:

0683p000009Lul9.png

 

It is odd because this Distinct Child Element component works with an XML input, as can be seen in the https://community.talend.com/t5/Design-and-Development/quot-Group-By-quot-in-data-mapper/td-p/177449  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.

 

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

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

View solution in original post

5 Replies
mayo
Contributor III
Contributor III
Author

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.

Anonymous
Not applicable

Hi,

 

Could you try with:

0683p000009Lvj3.png

mayo
Contributor III
Contributor III
Author

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.

Anonymous
Not applicable

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

mayo
Contributor III
Contributor III
Author

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