10 Lab Router
10 Lab Router
com +917411642061
Lab 13
Router
BANGALORE TECHNICAL TRAININGS..........................1 Onlinetrainingsbglr@gmail.com.....................................1 +917411642061.................................................................1 Lab 13...............................................................................1 Lab at a Glance................................................................2 Objectives..............................................................2 Summary................................................................2 Duration.................................................................3 Exercises..........................................................................4 Exercise 1: Import the Sources and Targets..........4 Exercise 2: Create the Mapping.............................5 Exercise 3: Create and Run the Workflow..............6 Reference.........................................................................8 Router vs. Filter Transformation.............................8
13 - 1
Lab at a Glance
The exercises in this lab are designed to walk the student through the process of using a Router transformation.
Objectives
After completing the lab, the student will be able to: Understand the functionality of the Router transformation. Apply the Router in a mapping where multiple filter conditions are required.
Summary
In this lab, the student will develop a mapping where a row can be sent to one (or multiple) of three different target tables. The mapping will use a Router transformation to group employee records based on various criteria, then route each record to the appropriate target table. SOURCE: TARGETS: ODS_EMPLOYEE_SALES ODS_EMPLOYEE_NON_SALES ODS_EMPLOYEE_ROOKIE The conditions for routing the records are as follows: ODS_EMPLOYEE_SALES should contain records for employees where the TYPE_CODE column contains the value SALES. ODS_EMPOYEE_NON_SALES should contain records for employees where the TYPE_CODE column contains the value FIN, ADMIN or MGR. ODS_EMPLOYEE_ROOKIE should contain records for employees whose start date (DATE_HIRED column) is less than 2 years from todays date.
13 - 2
Duration
This lab should take approximately 30 minutes.
13 - 3
Exercises
Exercise 1: Import the Sources and Targets
Step 1. Import source table.
Note that ODS_EMPLOYEE was loaded as a TARGET in a previous lab. The data in it actually represents intermediate data that requires further processing. So, in this lab, the same ODS_EMPLOYEE will act as a SOURCE. The mapping needs to source the table in the target database, and load different tables in the target database. Resultingly, there are now two instances of the ODS_EMPLOYEE table in your student folder -- a source definition and target definition.
Open the Studentxx folder. Open the Source Analyzer. Right-click anywhere in the work area and select Clear All. Import the relational source ODS_EMPLOYEE from the tdbuxx database schema. (The table being sourced resides in the target database.)
Step 2. Import target tables. Clear the Warehouse Designer workspace by rightclicking anywhere in the work area and selecting Clear All. Import the relational targets ODS_EMPLOYEE_SALES, ODS_EMPLOYEE_NON_SALES and ODS_EMPLOYEE_ROOKIE from the tdbuxx database schema.
13 - 4
Add the ODS_EMPLOYEE_SALES, ODS_EMPLOYEE_NON_SALES and ODS_EMPLOYEE_ROOKIE target definitions. Step 2. Create a router transformation. Create a Router transformation rtr_ODS_EMPLOYEE_TYPE. and name it
Copy/Link all of the ports from sq_ODS_EMPLOYEE to rtr_ODS_EMPLOYEE_TYPE. Edit the rtr_ODS_EMPLOYEE_TYPE transformation and select the Groups tab. Click on the Add a new group button:
Rename NEWGROUP to SALES. Ignore the Default group; it will not be used. Add the following Group Filter Condition:
The Router tests each row against every group condition, so a row can exit the transformation multiple times. When the row does not meet any condition, it is placed in the Default Group. The row can exit the default group if the ports are linked to another transformation, or simply terminate there.
TYPE_CODE = 'SALES' Add two more groups named NON_SALES and ROOKIES. For the NON_SALES group, add a filter condition that checks for a TYPE_CODE of ADMIN, FIN or MGR. TYPE_CODE = 'ADMIN' OR TYPE_CODE = 'FIN' OR TYPE_CODE = 'MGR'
13 - 5
For the ROOKIES group, check for a hire date that is less than 2 years (730 days) from todays date. Use the following condition:
SESSSTARTTIME is a system variable providing the system date value when the session started.
DATE_DIFF (SESSSTARTTIME, DATE_HIRED, 'dd') < 730 If it is not the last group, select the DEFAULT group and move it to the bottom. Order does not matter to row evaluation, but is helpful for clarity. Click OK. Step 3. Link target definitions. Link the ports from the various groups within rtr_ODS_EMPLOYEE_TYPE to their corresponding columns in the three target definitions. Save the repository.
Select the Mapping tab. In the Navigation box, select the source sq_ODS_EMPLOYEE. Under Connections, click on the down arrow , select native_target_xx (where xx represents the assigned student number) because the table being sourced resides in the target database. Click OK.
In the Navigation box, select each of the three targets. Under Connections, click on the down arrow select native_target_xx and click OK. ,
Under Properties, the Target load type should be defaulted to Normal. Scroll down to select the Truncate target table option.
13 - 6
Link Start to s_m_ODS_EMPLOYEE_TYPE_xx: Save, validate and start wf_ODS_EMPLOYEE_TYPE_xx. Monitor and review the results for s_m_ODS_EMPLOYEE_TYPE_xx in the Workflow Monitor. Step 2. Verify results session properties.
ODS_EMPLOYEE_NON_SALES
13 - 7
ODS_EMPLOYEE_ROOKIE
Results will vary with todays date.
Reference
Router vs. Filter Transformation
A Router transformation is similar to a Filter transformation in that both transformations allow testing of data based on a condition. The Filter tests rows against one condition and drops the rows that do not match. A Router transformation tests each row against one or more conditions, called groups. If a condition is met, the transformation flags the row as true - allowing it to pass through that group. Each row will be tested against every group. A row can be dispersed across many groups, if the conditions are met. An advantage of the Router over the Filter is, if a row does not meet any of the defined group conditions, the row will route to the default group. This makes the Router transformation work well for error handling.
13 - 8