If you want to populate the multiple records of a single row in data processing in Talend Open Studio then tSplitRow component helps splitting one input row into several output rows.
To understand tSplitRow component functionality, we are creating a sample job here -
Example - In the below table, you can see that every person has three addresses and we want to create multiple records for every person based on their addresses.
Id
|
First Name
|
Last Name
|
Address1
|
Address2
|
Address3
|
1
|
Ryan
|
Arjun
|
New Delhi, India
|
Noida, India
|
Ghaziabad, India
|
2
|
Kimmy
|
Wang
|
Taipei, Taiwan
|
Taichung, Taiwan
|
Kaohsiung, Taiwan
|
3
|
Rosy
|
Gray
|
London, UK
|
Manchester, UK
|
York, UK
|
4
|
Will
|
Smith
|
Tokyo, Japan
|
Kyoto, Japan
|
Chiba, Japan
|
5
|
John
|
Godson
|
Stockholm, Sweden
|
Goeteborg, Sweden
|
Malmoe, Sweden
|
where connect each component by right clicking and select Row > Main using the following components -
- tRowGenerator component generates as many rows and fields as are required using random values taken from a list. It can be used to create an input flow in a Job for testing purposes, in particular for boundary test sets. You need to the following setting in tRowGenerator Editor window
- tLogRow component allows you to write data, that is flowing through your Job (rows), to the console. Here, we have to connect our tRowGenerator component to tLogRow component for showing the data output to the console.
- tSplitRow component helps splitting one input row into several output rows and we have to connect our tLogRow component to tSplitRow component and have to do the following settings in column mapping sections -
- tLogRow component to show the output from tSplitRow component.
Id
|
FullName
|
Address
|
1
|
Ryan Arjun
|
New Delhi, India
|
1
|
Ryan Arjun
|
Noida, India
|
1
|
Ryan Arjun
|
Ghaziabad, India
|
2
|
Kimmy Wang
|
Taipei, Taiwan
|
2
|
Kimmy Wang
|
Taichung, Taiwan
|
2
|
Kimmy Wang
|
Kaohsiung, Taiwan
|
3
|
Rosy Gray
|
London, UK
|
3
|
Rosy Gray
|
Manchester, UK
|
3
|
Rosy Gray
|
York, UK
|
4
|
Will Smith
|
Tokyo, Japan
|
4
|
Will Smith
|
Kyoto, Japan
|
4
|
Will Smith
|
Chiba, Japan
|
5
|
John Godson
|
Stockholm, Sweden
|
5
|
John Godson
|
Goeteborg, Sweden
|
5
|
John Godson
|
Malmoe, Sweden
|
To Learn more, please visit our blog at -
http://www.sql-datatools.com
To Learn more, please visit our YouTube channel at -
http://www.youtube.com/c/Sql-datatools
To Learn more, please visit our Instagram account at -
https://www.instagram.com/asp.mukesh/
To Learn more, please visit our twitter account at -
https://twitter.com/macxima
No comments:
Post a Comment