Working with Groups
A Router transformation has the following types of groups:
Input Group
The Rank transformation includes a single input group. The input group includes all input ports that you add to the transformation.
Output Groups
The Rank transformation includes the following types of output groups:
- User-Defined Groups
You create a user-defined group to test a condition based on incoming data. A user-defined group consists of output ports and a group filter condition. You can create and edit user-defined groups on the Groups tab with the Developer tool. Create one user-defined group for each condition that you want to specify.
The Data Integration Service uses the condition to evaluate each row of incoming data. It tests the conditions of each user-defined group before processing the default group. The Data Integration Service determines the order of evaluation for each condition based on the order of the connected output groups. The Data Integration Service processes user-defined groups that are connected to a transformation or a target in a mapping.
If a row meets more than one group filter condition, the Data Integration Service passes this row multiple times.
- The Default Group
The Developer tool creates the default group after you create one user-defined group. The Developer tool does not allow you to edit or delete the default group. This group does not have a group filter condition associated with it. If all of the group conditions evaluate to FALSE, the Data Integration Service passes the row to the default group. If you want the Data Integration Service to drop all rows in the default group, do not connect it to a transformation or a target in a mapping.
The Developer tool deletes the default group when you delete the last user-defined group from the list.
The Developer tool copies property information from the input ports of the input group to create a set of output ports for each output group. You cannot change or delete output ports or their properties.
Using Group Filter Conditions
You can test data based on one or more group filter conditions. You create group filter conditions on the Groups tab using the Expression Editor.
You can enter any expression that returns a single value. You can also specify a constant for the condition. A group filter condition returns TRUE or FALSE for each row that passes through the transformation, based on whether a row satisfies the specified condition. Zero (0) is the equivalent of FALSE. Any non-zero value is the equivalent of TRUE. You can use a single numeric port as a filter condition. The Data Integration Service passes the rows of data that evaluate to TRUE to each transformation or target that is associated with each user-defined group.
Note: You cannot use a single dynamic port to return a boolean value.
For example, you have customers from nine countries, and you want to perform different calculations on the data from three countries. You can use a Router transformation in a mapping to filter this data to three different Expression transformations.
You can use parameters as elements in the group filter condition. You can use system parameters or user-defined parameters. You can create parameters from the Expression Editor and add them to the expression.
The default group does not have a group filter condition. However, you can create an Expression transformation to perform a calculation based on the data from the other six countries.
The following figure shows a mapping with a Router transformation that filters data based on multiple conditions:
To perform multiple calculations based on the data from three different countries, create three user-defined groups and specify three group filter conditions on the Groups tab.
The following figure shows group filter conditions that filter customer data:
The following table shows group filter conditions that filter customer data:
Group Name | Group Filter Condition |
---|
France | customer_name=‘France’=TRUE |
Japan | customer_name=‘Japan’=TRUE |
USA | customer_name=‘USA’=TRUE |
In the mapping, the Data Integration Service passes the rows of data that evaluate to TRUE to each transformation or target associated with each user-defined group, such as Japan, France, and USA. The Data Integration Service passes the row to the default group if all of the conditions evaluate to FALSE. The Data Integration Service then passes the data of the other six countries to the transformation or target that is associated with the default group. If you want the Data Integration Service to drop all rows in the default group, do not connect it to a transformation or a target in a mapping.
The Router transformation passes data through each group that meets the condition. If data meets three output group conditions, the Router transformation passes the data through three output groups.
For example, you configure the following group conditions in a Router transformation:
Group Name | Group Filter Condition |
---|
Output Group 1 | employee_salary > 1000 |
Output Group 2 | employee_salary > 2000 |
When the Router transformation processes an input row data with employee_salary=3000, it routes the data through output groups 1 and 2.
Dynamic Ports in Group Filter Conditions
You can use a dynamic port in a group filter condition. The Data Integration Service applies the filter condition to each generated port in the dynamic port.
For example, a dynamic port, MyDynamicPort, contains three decimal ports:
Salary
Bonus
Stock
You might configure the following group filter condition:
MyDynamicPort > 100
The group filter condition expands to the following expression:
Salary > 100 AND Bonus > 100 AND Stock > 100
Each generated port must be a valid type for the expression.
Parameterize the Group Filter
You can use an expression parameter to define a group filter. An expression parameter is a parameter that contains a complete expression.
For example, an expression parameter might contain the expression
Employee_Salary > 1000.
To parameterize the group filter, choose New Parameter in the Group Filter Condition field of the Groups tab. Define the parameter and enter the expression on the Expression Editor. An expression parameter cannot contain other parameters.
The following image shows the Groups tab in the transformation properties:
When you use an expression parameter, the Developer tool cannot validate the expression. If the expression is not valid at run time, the mapping might fail.
Adding Groups
When you add a group, the Developer tool copies property information from the input ports to the output ports.
1. Click the Groups tab.
2. Click the New button.
3. Enter a name for the group in the Group Name section.
4. Click the Group Filter Condition field to open the Expression Editor.
5. Enter the group filter condition.
6. Click Validate to check the syntax of the condition.
7. Click OK.