Table of Contents

Search

  1. Preface
  2. Mappings
  3. Mapplets
  4. Mapping Parameters
  5. Where to Assign Parameters
  6. Mapping Outputs
  7. Generate a Mapping from an SQL Query
  8. Dynamic Mappings
  9. How to Develop and Run a Dynamic Mapping
  10. Dynamic Mapping Use Cases
  11. Mapping Administration
  12. Export to PowerCenter
  13. Import From PowerCenter
  14. Performance Tuning
  15. Pushdown Optimization
  16. Partitioned Mappings
  17. Developer Tool Naming Conventions

Developer Mapping Guide

Developer Mapping Guide

Step 3. Configure the Aggregator Transformation

Step 3. Configure the Aggregator Transformation

Add an Aggregator transformation to the mapping and configure dynamic ports to receive any new and changed columns from the Joiner transformation. Create an aggregate expression to calculate the total price of customer orders and group the aggregation by customer.
  1. Add an Aggregator transformation Agg_CustomerOrders to the mapping.
  2. Create dynamic ports in the Aggregator transformation:
    1. From the Output group in the Joiner transformation, drag the From_Read_CUSTOMER dynamic port to the Aggregator transformation.
      A dynamic port From_Read_CUSTOMER appears in the Aggregator transformation.
    2. From the From_Read_ORDERS dynamic port of the Output group in the Joiner transformation, drag the O_TOTALPRICE_DTL generated port to the Aggregator transformation.
    The following image shows the ports from the Joiner transformation linked to the Aggregator transformation:
    The mapping contains the Read_CUSTOMER, Read_ORDERS, Join_CustomerOrders, and the Agg_CustomerOrders transformations. The All Ports groups from the Read transformations are linked to the two dynamic ports in the Joiner transformation. The From_Read_CUSTOMER dynamic port from the Output group in the Joiner transformation is linked to a dynamic port in the Aggregator transformation. The O_TOTALPRICE_DTL generated port from the From_Read_ORDERS dynamic port of the Output group in the Joiner transformation is linked to a port in the Aggregator transformation.
  3. In the
    Properties
    view, click the
    Ports
    tab.
  4. Click the
    New
    button to create a port to aggregate prices of the orders.
    The Ports tab contains the New, Cut, Copy, Paste, Delete, Move Up, and Move Down buttons.
    The Developer tool creates a new port called Field.
  5. Select the new port, and change the column values as follows:
    • Name: O_TOTALAMOUNT
    • Type: decimal
    • Precision: 10
    • Scale: 2
    • Input: Clear the selection to make this port an output-only port.
    The following image shows the ports in the Aggregator transformation:
    The Ports tab in the Properties view of the Aggregator transformation lists the dynamic port and the two ports in the Aggregator transformation.
  6. In the Expression column for the O_TOTALAMOUNT port, click the
    Open
    button.
    The Ports tab lists the ports in the Aggregator transformation. O_TOTALAMOUNT column is select and the Expression column for the port contains the Open button.
    The
    Aggregator Expression
    window appears.
  7. Replace the existing expression in the editor with the following expression:
    SUM(O_TOTALPRICE_DTL)
    The Aggregator Expression dialog box has Functions, Ports, and Parameters tab. The dialog box has an Expression editor area. The Ports tab shows the ports in the Aggregator transformation. The Expression editor contains the expression SUM(O_TOTALPRICE_DTL).
  8. Click
    Validate
    to validate the expression.
  9. Click
    OK
    .
  10. Click
    OK
    to exit the
    Aggregator Expression
    editor.
  11. In the
    Properties
    view, click the
    Group By
    tab.
  12. Specify the group by port to aggregate the total price by market segment as follows:
    1. Make sure that
      Value
      from the
      Specify by
      list is selected.
    2. Click
      Choose
      .
      The
      Ports
      dialog box appears.
    3. Select the checkbox next to C_CUSTKEY and click
      OK
      .
      The following image shows the selected group by port:
      The Group By tab shows that the group by property is specified as a value and the port C_CUSTKEY is listed as a group by port.
You can preview the Aggregator transformation data to make sure that it contains the expected results. In the mapping editor, right-click the Aggregator transformation and select
Run Data Viewer
. The data calculated by the transformation appears in the
Data Viewer
view.
The Data Viewer tab shows the output of the data preview. You can preview the data for C_CUSTKEY, C_NAME, C_ADDRESS, C_NATIONKEY, C_PHONE, C_ACCTBAL, C_MKTSEGMENT, O_TOTALAMOUNT, and O_TOTALPRICEDTL.

0 COMMENTS

We’d like to hear from you!