Академический Документы
Профессиональный Документы
Культура Документы
com/datastage-loop-with-transformer/
In this example, we will add the rank columns that indicate the descending order
mydatahack on
of the transaction date per customer.
Introduction to Dense
Layers for Deep
Input
Learning with Keras
(https://www.mydatahack.com
/introduction-to-
dense-net-with-
keras/#comment-5)
haramoz on
Introduction to Dense
1 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
mydatahack on
Salesforce API with
Simple Salesforce
For Python
(https://www.mydatahack.com
/salesforce-api-with-
Output simple-salesforce-
for-python
/#comment-3)
LeMaurien19 on
Salesforce API with
Simple Salesforce
For Python
(https://www.mydatahack.com
/salesforce-api-with-
simple-salesforce-
for-python
/#comment-1)
Steps
Recent Posts
How to Restore
AdventureWorks to
SQL Server Express
(https://www.mydatahack.com
/how-to-restore-
adventureworks-to-sql-
server-express/)
How to Connect to
Locally Installed SQL
Server Express with
JDBC
(1) Before the transformer stage, we need to sort the input data by Cust_Id in (https://www.mydatahack.com
ascending order and Trans_Date in descending order. /how-to-connect-to-
locally-installed-sql-
server-express-with-
jdbc/)
2 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
Express
(https://www.mydatahack.com
/how-to-enable-user-
login-with-sql-server-
express/)
Archives
November 2018
(https://www.mydatahack.com
/2018/11/)
October 2018
(3) Set the inputs partition in the Transformer stage to ‘same’. Make sure the (https://www.mydatahack.com
perform sort is unticked. /2018/10/)
September 2018
(https://www.mydatahack.com
/2018/09/)
August 2018
(https://www.mydatahack.com
/2018/08/)
July 2018
(https://www.mydatahack.com
/2018/07/)
June 2018
(https://www.mydatahack.com
/2018/06/)
(4) Set Stage Variables as below May 2018
3 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
(5) Set Loop Condition as Loop While: @ITERATION <= svBreakloop March 2018
(https://www.mydatahack.com
(6) Set Loop Variable as LoopVar = GetSavedInputRecord(). This LoopVar will /2018/03/)
become the Rank column. February 2018
(https://www.mydatahack.com
/2018/02/)
January 2018
(https://www.mydatahack.com
/2018/01/)
December 2017
(https://www.mydatahack.com
/2017/12/)
November 2017
(https://www.mydatahack.com
/2017/11/)
October 2017
(https://www.mydatahack.com
/2017/10/)
September 2017
(https://www.mydatahack.com
/2017/09/)
August 2017
Example 2: Aggregation (https://www.mydatahack.com
/2017/08/)
We will use the same data in Example 1 and create a column that has the total
purchased unit count per customer.
Input
Same as Example 1
Output
4 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
Steps
(1) As in the example 1, we need to sort the input data by Cust_Id and set hash
partition.
(2) Set Stage Variable as below. The order of the variables have to be kept. The
key idea here is Stage Variables are executed from top to bottom. At the last row
in the group, svSumUnits gets reset after the total unit is calucated as
svTotalUnits.
svInput = SaveInputRecord()
svLastRowInGroup = LastRowInGroup(lnk_trans.Cust_Id)
svTotalUnits = if svLastRowInGroup then svSumUnits + lnk_trans.Units
Else 0
svSumUnits = if svLastRowInGroup then 0 Else svSumUnits +
lnk_trans.Units
svBreakLoop = if svLastRowInGroup then svInput Else 0
(3) Set the while loop condition as Loop While: @ITERATION <=
svBreakLoop. You need to set LoopVar= GetSavedInputRecord(). Using
SaveInputRecord() without GetSavedInputRecord() results in a compilation error.
5 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
In the final example, we use the while loop in the transformer stage to perform
vertical pivoting operation. Input records show employers and 3 columns that list
their skill set. We will vertically transpose this table to list employers’ skillset in a
single column as in the output.
Input
Output
6 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
Steps
(2) Set Loop Variable as below. Each iteration will add empl_id, and skill column 1,
2 or 3 according to the iteration variable (@ITERATION).
7 of 8 18-11-2018, 09:22:48
DataStage: Loop With Transformer – MyDatahack https://www.mydatahack.com/datastage-loop-with-transformer/
SIMILAR NEWS
(https://www.mydatahack.com
/running-jobs-with- (https://www.mydatahack.com(https://www.mydatahack.com
ETL /how-to-rename-mapping-job-
informatica-cloud-rest-api/) /tips-and-troubleshooting-for- ETL
uploading-csv-to-database-in-in-informatica-cloud/)
ETL
Running Job… talend/)
How To Rena…
Informatica Cloud offers Tips and Tro…
Mappings are where all
REST API for us to
There will be time when the magic happens in
interact with the
you want to upload a Informatica Cloud.
platform
big csv file (with many When I started using it,
programmatically. At
rows and hundreds of it took me a while to
columns) to a relational
© 2017
MyDataHack.com
8 of 8 18-11-2018, 09:22:48