Table of Contents

Search

  1. Preface
  2. Transformations
  3. Source transformation
  4. Target transformation
  5. Aggregator transformation
  6. Cleanse transformation
  7. Data Masking transformation
  8. Deduplicate transformation
  9. Expression transformation
  10. Filter transformation
  11. Hierarchy Builder transformation
  12. Hierarchy Parser transformation
  13. Hierarchy Processor transformation
  14. Input transformation
  15. Java transformation
  16. Java transformation API reference
  17. Joiner transformation
  18. Labeler transformation
  19. Lookup transformation
  20. Mapplet transformation
  21. Normalizer transformation
  22. Output transformation
  23. Parse transformation
  24. Python transformation
  25. Rank transformation
  26. Router transformation
  27. Rule Specification transformation
  28. Sequence Generator transformation
  29. Sorter transformation
  30. SQL transformation
  31. Structure Parser transformation
  32. Transaction Control transformation
  33. Union transformation
  34. Velocity transformation
  35. Verifier transformation
  36. Web Services transformation

Transformations

Transformations

Hierarchical to hierarchical example

Hierarchical to hierarchical example

You want to create a customer order file in hierarchical format using an existing file of hierarchical data.
The existing customer order file, CompanyOrders, contains the names of companies who have placed orders and information about each order, including the price, date, shipping address, and ID numbers of ordered items. The following image shows the structure of the CompanyOrders file: The CompanyOrders file contains a CompanyName string and Orders array of structs. The Orders struct contains OrderPrice, OrderDate, Street, CIty, State, Country, ZipCode, and Items array of structs. The Items struct contains ItemId, ItemName, ItemPrice, and ItemQuantity.
You want to restructure the shipping address into a struct and add a field to calculate the total price of all orders for each company.
You will perform the following tasks to create and configure the target file:
  1. Design the mapping.
  2. Configure the output group.
  3. Create an output field to aggregate the total price.
  4. Create an output struct for the order address.
  5. Run the mapping.
Design the mapping.
Use the Mapping Designer to perform the following steps:
  1. Add the CompanyOrders file as a source object.
  2. Add a Hierarchy Processor transformation to the mapping and connect CompanyOrders as an input source.
  3. In the Hierarchy Processor transformation, set the
    Data Format
    to
    Hierarchical
    .
    An output group is created.
  4. Add a Target transformation to the mapping, and connect the Hierarchy Processor transformation output to this target object.
The following image shows the mapping: A mapping in the Mapping Designer shows the CompanyOrders source connected to the Hierarchy Processor transformation input. The Hierarchy processor transformation is connected to the target transformation.
Configure the output group.
In the Hierarchy Processor transformation, perform the following steps:
  1. Add all the incoming fields from the input to the output group. Set
    Add
    to
    Preserve incoming field
    .
    The following image shows the
    Add Field
    dialog: The Add Field dialog box shows the incoming field set to Input, Add set to Preserve incoming field, and Output Group or Field set to Output.
  2. Verify that the data source for the output group is set to
    Input
    .
Create an output field to aggregate the total price.
Perform the following steps to create a field that calculates the total price of all orders for each company:
  1. Add a new output field with the following properties:
    Property
    Value
    Child Of
    Output
    Name
    TotalOrdersPrice
    Type
    double
    Aggregate Options
    Enabled
    Output Field
    Orders
    The following image shows the aggregate options for the TotalOrdersPrice output field: The "New output field" dialog box shows the properties for the TotalOrdersPrice field. The Aggregate Options are highlighted where the "use this field to aggregate values in an output field array" checkbox is selected and the Output Field is set to Orders.
  2. Configure the following field expression for Output.TotalOrdersPrice to aggregate the total price of all orders for a company:
    SUM(:fld.{Output.Orders.Orders.OrderPrice})
Create an output struct for the order address.
Perform the following steps to structure the order address in the output:
  1. Add a new output field with the following properties:
    Property
    Value
    Child Of
    Output.Orders.Orders
    Name
    OrderAddress
    Type
    struct
    Struct Name
    Address
  2. Add all the incoming fields from Orders to OrderAddress. Set
    Add
    to
    Add primitive single occurring children
    .
  3. Set the data source for OrderAddress to
    Use Output
    .
  4. Delete the following fields from the OrderAddress struct that you do not need:
    • Output.Orders.Orders.OrderAddress.OrderPrice
    • Output.Orders.Orders.OrderAddress.OrderDate
  5. Delete the following fields from the Orders output group that you do not need:
    • Output.Orders.Orders.Street
    • Output.Orders.Orders.City
    • Output.Orders.Orders.State
    • Output.Orders.Orders.Country
    • Output.Orders.Orders.ZipCode
The following image shows the OrderAddress struct: The Hierarchy Processor transformation output fields shows the final hierarchical structure of the output. The OrderAddress struct is highlighted, where OrderAddress is a struct that contains the string values Street, City, State, Country, and ZipCode.
Run the mapping.