Sie sind auf Seite 1von 7

Sorter Transformation

Sorter transformation is an active and connected transformation used to sort the data. The data can be
sorted in ascending or descending order by specifying the sort key. You can specify one or more ports as
a sort key and configure each sort key port to sort in ascending or descending order. You can also
configure the order of the ports in which the integration service applies to sort the data.

The sorter transformation is used to sort the data from relational or flat file sources. The sorter
transformation can also be used for case-sensitive sorting and can be used to specify whether the
output rows should be distinct or not.

Creating Sorter Transformation


Follow the below steps to create a sorter transformation
1. In the mapping designer, create a new mapping or open an existing mapping
2. Go the toolbar->Click on Transformation->Create
3. Select the Sorter Transformation, enter the name, click on create and then click on Done.
4. Select the ports from the upstream transformation and drag them to the sorter transformation. You
can also create input ports manually on the ports tab.
5. Now edit the transformation by double clicking on the title bar of the transformation.
6. Select the ports you want to use as the sort key. For each selected port, specify whether you want
the integration service to sort data in ascending or descending order.

Configuring Sorter Transformation


Configure the below properties of sorter transformation
Case Sensitive: The integration service considers the string case when sorting the data. The
integration service sorts the uppercase characters higher than the lowercase characters.
Work Directory: The integration service creates temporary files in the work directory when it is
sorting the data. After the integration service sorts the data, it deletes the temporary files.
Distinct Output Rows: The integration service produces distinct rows in the output when this
option is configured.
Tracing Level: Configure the amount of data needs to be logged in the session log file.
Null Treated Low: Enable the property, to treat null values as lower when performing the sort
operation. When disabled, the integration service treats the null values as higher than any other
value.
Sorter Cache Size: The integration service uses the sorter cache size property to determine the
amount of memory it can allocate to perform sort operation

Performance improvement Tip

Use the sorter transformation before the aggregator and joiner transformation and sort the
data for better performance.
While using the sorter transformation, configure sorter cache size to be larger than the input
data size.
Configure the sorter cache size setting to be larger than the input data size while using sorter
transformation.
At the sorter transformation, use hash auto keys partitioning or hash user keys partitioning.

Sorter Transformation Example with 1 key


Problem statement: Sort the employee table based on their DEPARTMENT_ID.

Solution:
Create a new mapping m_Employees_Sorter by Go to toolbar -> click mapping-> Create
Drag Source (HR.Employees) and Target (TARGET.Employees) to the mapping.
Add Sorter Transformation by Go to Toolbar->click Transformation -> Create. Select the Sorter
transformation

Name it srt_Employees.
Drag all the columns from the source qualifier and drop them to the sorter transformation
Double click on srt_Employees and navigate to the Ports tab. Check Key for those columns
those you want to sort in Ascending/Descending order. In our case well select the
DEPARTMENT_ID as the key:

In the Properties tab:


Select 'Case Sensitive' if you want to sort case sensitive while comparisons.
Select 'Distinct' if you want to remove duplicate records.
Select 'Null Treated Low' if you want to Null value in a port is treated lower or higher than any
other value.

Click OK
Drag all the ports from srt_Employees to the target table Employees:

Click on Mapping ( from tool bar) -> then Validate ( to validate the mapping)
Now save the mapping ( by clicking on Repository-> Save or you can also press Ctrl+S)
Generate the workflow and run it
Sorter Transformation Example with more than 1 key
Problem statement: Sort the employee table based on their DEPARTMENT_ID and SALARY.

Solution:
Use the previous example, only in the Ports tab of the sorter transformation select SALARY and
DEPARTMENT_ID as keys. Also shift SALARY below DEPARTMENT_ID in the list as the column which
comes first in the list has priority in sort order.
Sorter Transformation to get unique records after Union
Problem Statement: Remove the duplicate rows coming from the union transformation before
loading into the target table.
Solution:
Use the mapping that weve previously created for Union transformation example:

Disconnect the links from the union transformation to the target table and insert a sorter
transformation between them. Link the output ports of the union transformation to the sorter
tranformation:
In the Properties tab select the Distinct option. Youll notice that in the Ports tab all the
columns automatically get selected as Key:

Click OK
Drag all the ports from srt_Employees to the target table Employees:

Click on Mapping ( from tool bar) -> then Validate ( to validate the mapping)
Now save the mapping ( by clicking on Repository-> Save or you can also press Ctrl+S)
Generate the workflow and run it

Das könnte Ihnen auch gefallen