Aggregator Transformation in Informatica with Example

โšก Smart Summary

Aggregator transformation in Informatica is the active object that performs calculations such as sum, average and count across a group of rows, holding those rows in an aggregate cache until each group is complete.

  • ๐Ÿงฎ Grouped calculation: Group by ports define the groups, and the Integration Service returns one row for every unique combination.
  • ๐Ÿ’พ Two caches: Group values are held in the index cache while row data is held in the data cache.
  • ๐Ÿงช Worked example: The expression sum(SAL) grouped by DEPTNO loads department totals into SUM_SAL_DEPTWISE.
  • ๐Ÿ”€ Sorted input: Presorting on the group by ports lets the Integration Service release each group early and cache far less data.
  • ๐Ÿ“ˆ Incremental runs: Incremental aggregation reuses the historical cache so only new source rows are calculated.
  • ๐Ÿšซ Nesting limit: A single transformation may hold single-level functions or nested functions, never both.

Aggregator Transformation in Informatica

What is Aggregator Transformation?

Aggregator transformation is an active transformation that performs aggregate calculations such as sum, average and count.

For example, if you want to calculate the sum of salaries of all employees department wise, you can use the Aggregator transformation.

The aggregate operations are performed over a group of rows, so a temporary placeholder is required to store all these records and perform the calculations.

For this, the aggregator cache is used. This is temporary main memory allocated to the Aggregator transformation to perform such operations, and it is held in two parts: the index cache stores the group values while the data cache stores the row data being aggregated.

The transformation is active because it changes the number of rows in the pipeline. Several thousand employee records can enter it and only one row per department leaves it.

How to Use Aggregator Transformation in Informatica

In this example, we will calculate the sum of salaries department wise. For this, we require a new column to store this sum. So, first of all, we will prepare a new column.

Step 1) Create a new database target table, for example, say “sum_sal_deptwise”, using the script below. You will see the new database target table created under the Targets folder in the next step.

Download the above Create_table_sal_deptwise.txt File

Step 2) Create a new mapping “m_sum_sal_deptwise”.

In order to create the new mapping, we need the source table (EMP) and the target table (sum_sal_deptwise) in Mapping Designer, so we need to

  1. Import the target table “sum_sal_deptwise” in the mapping.
  2. Import the source table “emp”.

Both definitions now appear on the canvas, as shown below.

Mapping Designer with the EMP source, SQ_EMP and the imported SUM_SAL_DEPTWISE target

Step 3) In the mapping,

  1. From the Source Qualifier, delete the columns empno, ename, job, mgr, hiredate and comm, leaving only the columns deptno and sal.
  2. Create a new Aggregator transformation using the toolbox menu as shown in the screenshot. When you click the aggregator icon, a new Aggregator transformation will be created.

The new AGGTRANS object appears beside the trimmed Source Qualifier.

Aggregator icon on the toolbar creating AGGTRANS next to the trimmed SQ_EMP

Step 4) Drag and drop the SAL and DEPTNO columns from the Source Qualifier (SQ_EMP) to the Aggregator transformation. The two ports are now linked into AGGTRANS.

SAL and DEPTNO ports dragged from SQ_EMP into the AGGTRANS Aggregator transformation

Step 5) Double-click the Aggregator transformation to open its properties, and then

  1. Add a new port in the transformation
  2. Rename the port to SUM_SAL
  3. Change the data type of this new port to double
  4. Make this port an output port by selecting the checkbox of the output port
  5. Click the expression option

The Ports tab now lists SAL, DEPTNO and the new SUM_SAL output port.

Ports tab of AGGTRANS with the new SUM_SAL output port set to the double data type

Step 6) In the Expression Editor window

  1. Add the expression sum(SAL); you have to write this expression yourself.
  2. Select the OK button, this will bring back the Edit Transformations window.

The Expression Editor shows the aggregate expression assigned to SUM_SAL.

Expression Editor for the SUM_SAL port holding the aggregate expression sum(SAL)

Step 7) In the Edit Transformations window, select the option “GroupBy” by marking the check box against the deptno column and click OK. By selecting group by against deptno, we are instructing Informatica to group salaries by deptno.

Ports tab with the GroupBy checkbox selected against the DEPTNO port

Step 8) Link the deptno and sum_sal columns from the Aggregator transformation to the target table. The mapping is then complete from source to target.

DEPTNO and SUM_SAL linked from AGGTRANS to the SUM_SAL_DEPTWISE target definition

Now save the mapping and execute it after creating a new session for this mapping. The target table would contain the sum of salaries department wise. In this way, we can use the Aggregator transformation to calculate aggregate results.

Group By Ports in Aggregator Transformation

The step above marked a single port as Group By, which is what turned a company-wide total into one total per department. Any input, input/output, output or variable port can be marked in the same way.

Three rules govern the result set:

  • One row per group. When values are grouped, the Integration Service produces one row for each unique combination of the group by ports.
  • No group by, one row. If no port is marked, the whole input is treated as a single group and one row is returned for all input rows.
  • The last row wins. Alongside the aggregate result, the Integration Service usually passes the last row received in the group, unless a function such as FIRST names a different row.

Where several ports are marked, port order decides the grouping order, and the order can change the result. Grouping by DEPTNO and then JOB is not the same as grouping by JOB and then DEPTNO, because the second column values are not necessarily unique.

Aggregator Transformation Properties

The Properties tab of the Edit Transformations window carries the settings that decide where the cache lives and how much of it is used. The table below lists them.

Setting What it controls
Cache Directory Local directory in which the Integration Service creates the index and data cache files. The default is the $PMCacheDir process variable set in Workflow Manager.
Tracing Level Amount of detail written to the session log for this transformation.
Sorted Input Declares that incoming data is already sorted by the group by ports. Select it only when the mapping really does deliver sorted data.
Aggregator Data Cache Size Size of the data cache. The default is 2,000,000 bytes, and Auto lets the Integration Service size it.
Aggregator Index Cache Size Size of the index cache. The default is 1,000,000 bytes, and Auto lets the Integration Service size it.
Transformation Scope Applies the logic to each transaction, or to all incoming data. All Input drops the incoming transaction boundaries.

When incremental aggregation is enabled, the Integration Service writes a backup of the cache files on every run, so the cache directory has to hold two sets of files rather than one.

Aggregate Expression Rules and Performance Tips

An aggregate expression may combine an aggregate function with conditional clauses and non-aggregate functions, which makes conditional sums and counts possible inside one port. Two rules constrain what can be written.

  • One level of nesting. Only one aggregate function may be nested inside another, and the inner expression is evaluated first.
  • No mixing. A transformation may contain single-level functions or nested functions, never both. If it contains both, the Designer marks the mapping invalid, so split the logic across two Aggregator transformations.

On the tuning side, three settings do most of the work:

  • Sorted input. When rows arrive sorted by the group by ports, each group can be released as soon as its last row arrives, so far less data is cached and the session runs faster. Sorted input cannot be combined with incremental aggregation.
  • Incremental aggregation. New source rows are passed through the mapping and combined with the historical cache instead of recalculating history, which suits a nightly load onto a running total.
  • Filter early. Rows that will never contribute to a total should be dropped before the Aggregator, either in the Source Qualifier query or in a Filter transformation, because every row that reaches the Aggregator costs cache memory. This is one of the standard checks during performance tuning.

FAQs

The aggregate family covers AVG, COUNT, FIRST, LAST, MAX, MEDIAN, MIN, PERCENTILE, STDDEV, SUM and VARIANCE. Each returns a summary value for the non-null values in the selected port.

The entire input is treated as one group, so a single row is returned for all input rows. That row carries the aggregate result together with the last row the transformation received.

The index cache holds the group values, meaning the values of the ports marked Group By. The data cache holds the row data used in the calculation. Overflow from either is written to cache files.

It passes only new source data through the mapping and combines it with the historical cache from earlier runs, so totals are updated instead of rebuilt. It cannot be combined with the sorted input option.

By default the Integration Service treats nulls as NULL and skips them, so a sum ignores empty salaries. The service can instead be configured to treat null values in aggregate functions as zero.

Into the directory named by the Cache Directory setting, which defaults to the $PMCacheDir process variable configured in Workflow Manager. Make sure that directory exists and has enough free disk space.

AI assistants profile source data and workload history to suggest where a total belongs, which grouping keys matter and where a calculation is cheaper in the database. Machine learning based advisors rank the options, and an engineer approves them.

Copilot drafts expressions and the surrounding SQL quickly, which saves time on repetitive port work. It cannot see your cache sizes or port order, so validate every suggestion in the Expression Editor before saving.

Summarize this post with: