Tuesday, April 21, 2015

How to combine multiple records to single records using tDenormalize ?

In this post will see how to combine multiple records separated by comma to a single column, below I have used a basic example which will help you to understand the logic behind the component. After this post you should be able to apply the same logic in your jobs.

tDenormalize: This component is reverse of tNormalize. In tNormalize it split records to multiple records .Here in tDenormalize it combine multiple records to single records.

This is output of tnormalize as shown in previous post .Here this is used as Input file.

Supplier_ID;Supplier_Name;Supplier_Products
101;Nick Pvt Ltd;Desktop
101;Nick Pvt Ltd;Laptop
101;Nick Pvt Ltd;Mobiles
102;Shiny Shipping;WiFi Routers
102;Shiny Shipping;PC
102;Shiny Shipping;Networking Wires
103;Michael Pvt Ltd;RAM
103;Michael Pvt Ltd;Hard-Disk
103;Michael Pvt Ltd;Servers
104;Rose Marry Ship Pvt Ltd;Pen Drive
104;Rose Marry Ship Pvt Ltd;DDR Memory
104;Rose Marry Ship Pvt Ltd;Tablet
105;Mark Pvt Ltd;Watch
105;Mark Pvt Ltd;Refrigerator
105;Mark Pvt Ltd;CD

1. Create metadata as shown in previous post (tNormalize example) Metadata > File Delimited > Denormalize.Then drag it to the design workspace and select tFileInputDelimited component from the Popup. 
2. Drag following components from palette: tDenormalize,tlogrow.
tdenormalize component is used to combine values from multiple records.We have taken Supplier_Products column to denormalize.
tlogrow is used to display the output.
3.Connect the components using Row > Main connections.

Open the component properties of the tDenormalize component click on Sync columns to propogate the metadata then select Supplier_Products option from dropdown list in to denormalize section.Write "," as delimiter and tick checkbox of Merge same value.



Open the component properties of tLogRow and select in Basic Settings Table (print values in cell of a table) to show result in table format.

Then Run the job.
You can see that 15 rows are denormalized into 5 rows.


We have taken 15 rows in our input and it is resulted in 5 rows as a output .
15 multiple records are combined into 5 single records.This is Denormalization.

No comments:

Post a Comment