6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.
-
Upload
cathleen-nash -
Category
Documents
-
view
214 -
download
0
Transcript of 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.
![Page 1: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/1.jpg)
6Copyright © 2009, Oracle. All rights reserved.
Using the Data Transformation Operators
![Page 2: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/2.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 2
Objectives
After completing this lesson, you should be able to:
• Describe the use of various Mapping Editor operators
• Use operators such as the Joiner, Lookup, Subquery Filter, Sequence, Splitter, and Pivot/Unpivot operators in mappings
• Identify the purpose and important properties of each of the operators
![Page 3: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/3.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 3
Lesson Agenda
• Overview of the following operators:– Joiner– Lookup– Subquery Filter– Sequence– Set– Splitter– Pivot/Unpivot– Aggregator– Constant– Transformation– Pre/Post Mapping
• Deploying and Executing
![Page 4: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/4.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 4
Component Palette
This lesson focuses on some of these operators.
![Page 5: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/5.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 5
Using a Joiner
A joiner is used to extract data from multiple sources and produce a single output row set.
Set the condition in the Join Condition property in the Property Inspector panel. Click the ellipses (…) to start the Expression Builder.
![Page 6: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/6.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 6
Setting the Join Condition
![Page 7: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/7.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 7
Setting the Joiner Input Role
T1 T2 Join
Standard Standard T1 Join T2
Standard Outer join T1 LEFT OUTER JOIN T2
Outer Join Standard T1 RIGHT OUTER JOIN T2
Outer Join Outer Join T1 FULL OUTER JOIN T2
![Page 8: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/8.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 8
Lookup Operator
Use the Lookup operator to look up data from a table, view, cube, or dimension.
![Page 9: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/9.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 9
Lookup Condition
You have an option of Freestyle Editing. You can write any arbitrary SQL lookup condition in the Lookup
Condition text box.
![Page 10: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/10.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 10
Handling Multiple Match Rows
![Page 11: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/11.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 12
Using the Subquery Filter Operator
You can build a subquery quickly and simply.
• By default, the EXISTS condition is used.
• You can change the subquery filter input role to IN, NOT IN, or NOT EXISTS.
Set the condition in the Subquery Filter Condition property in the Property Inspector panel. Click the ellipses (…) to start the Expression Builder.
![Page 12: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/12.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 13
Sequence Operator
• Generates sequential numbers that increment for each row
• Used to load identifiers that uniquely identifies each record in a table, or each level in a dimension
• Has two output groups:– NEXTVAL – CURRVAL
![Page 13: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/13.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 14
Set Operation Operator
![Page 14: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/14.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 15
Using the Splitter Operator for Multitable Insert
Select
Insert
SplitInsert
![Page 15: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/15.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 16
Quiz
If you have to extract data from multiple sources and produce a single output row set, which operator will you use:
a. Filter
b. Sequence
c. Splitter
d. Joiner
![Page 16: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/16.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 17
Pivot and Unpivot Operators
Year Q1_SALES Q2_SALES Q3_SALES Q4_SALES
2005 10000 20000 40000 80000
2006 12000 24000 48000 96000
2007 16000 32000 64000 128000
Year Quarter Sales
2005 Q1_SALES 10000
2006 Q1_SALES 12000
2007 Q1_SALES 16000
2005 Q2_SALES 20000
2006 Q3_SALES 48000
……
Pivot transformation operator enables you to transform a single row of attributes into multiple rows. Unpivot performs the reverse.
![Page 17: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/17.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 18
Wizard-Based Pivot Definition
Click Input Attributes. Note that YEAR is selected as the key column as this remains the same for each
pivoted row.
Click Output Attributes or click Next. Note that QUARTER is selected
as the Row locator column. This is the
pivot column.
Click Pivot transform.
You define how the row is transformed from a row with columns to a
number of rows.
![Page 18: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/18.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 19
Resulting Pivot Code and Mapping
![Page 19: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/19.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 20
Aggregator Operator
Performs data aggregations, such as SUM and AVG, and provides an output row set with aggregated data.
You can also define group by and having
clause.
![Page 20: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/20.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 21
Aggregator Operator
Add new output attributes here and in the Expression field click the ellipses to start the Expression
Builder
From the Function drop down list, select the function. Choose between ALL or DISTINCT. From the drop-down list, select the attribute on which the aggregation should be performed. Click
Use Above Values to get the expression in the text area.
![Page 21: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/21.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 22
Using a Constant Operator
Constant operator is used to provide constant values to target attributes.
![Page 22: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/22.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 23
Using the Expression Builder to Definea Constant Operator
![Page 23: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/23.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 24
Using the Transformation Operator
• Transformations are functions that are used to edit, cleanse, or change your data before it is loaded into the data warehouse.
• OWB currently supports:– SQL standard transformations– User-defined custom transform libraries– Sharing and reusability among modules– Local variables as inputs to a transformation
![Page 24: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/24.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 25
Transformation Library
User-defined, custom-defined functions or procedures local to the project also appear here.
Also, note Heterogeneous predefined categories of transformations.
• Makes available all applicable database functions
• Includes additional Warehouse Builder predefined functions and procedures
• Categorizes by transformation type for quick access
![Page 25: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/25.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 26
Transformation Details
![Page 26: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/26.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 27
Pre/Post Processing Operators
Use Pre/Post Processing operators to perform processing before or after executing a mapping.
Mapping Input Used to provide values into a mapping
Mapping Output Used to send out values from a mapping
Pre-Mapping Calls a procedure or function before executing the mapping
Post-Mapping Calls a procedure or function after executing the mapping
![Page 27: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/27.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 28
Pre/Post Mapping Operator: Example
Use a Pre-mapping process operator that will invoke a procedure to drop the indexes before the loading starts.
Use a Post-mapping process operator that will invoke a procedure to re-create the indexes after the loading is complete.
![Page 28: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/28.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 29
Lesson Agenda
• Overview of the following operators:– Joiner– Lookup– Subquery Filter– Sequence– Set– Splitter– Pivot/Unpivot– Aggregator– Constant– Transformation– Pre/Post Mapping
• Deploying and Executing
![Page 29: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/29.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 30
Deploying Database Objects and Mappings
• Deployment is the process of creating a target system from the logical design or model.
• When you deploy database objects, they get created in the target schema.
• When you deploy a mapping, the scripts or packages are generated (.ddl, .pls and so on).
• When you deploy, you should make sure the objects are deployed in correct sequence.– For example, for a mapping to deploy successfully, the
objects (tables, external tables, sequence, and so on) referenced in the mapping should have been deployed.
![Page 30: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/30.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 31
Deploying in Projects Navigator Panel
Right-click the object and select Deploy. In the Log panel, view the deployment details. Note that the deploy process involves validation, script generation and finally the creation of the object. In case of mappings, the scripts or packages are generated (.ddl, .pls and so on)
![Page 31: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/31.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 32
Executing a Mapping
![Page 32: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/32.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 33
Quiz
If you want to generate the total sales for each product, you will use the following operator in your mapping:
a. Joiner
b. Set
c. Aggregator
![Page 33: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/33.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 34
Summary
In this lesson, you should have learned how to:
• Describe the use of various transformation operators
• Use operators such as the joiner, lookup, subquery filter, sequence, splitter, and pivot/unpivot operators in mappings
• Identify the purpose and important properties of each of the operators
![Page 34: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/34.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 35
Practice 6-1 Overview: Using the Joiner, Sequence, and the Transformation Operator in a
Mapping
This practice covers the following topics:
• Creating a Mapping, MAP_GEOGRAPHY, that uses:– A Joiner operator to consolidate data from two staging
tables, Stg_Countries and Stg_Regions. – A Sequence operator to populate a primary key column in
the target– A sysdate Transformation operator to populate the
Load_Date column.
![Page 35: 6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.](https://reader035.fdocuments.us/reader035/viewer/2022062806/5697bf7a1a28abf838c82fdf/html5/thumbnails/35.jpg)
Copyright © 2009, Oracle. All rights reserved.6 - 36
Practice 6-2 Overview: Using the Subquery and the Lookup Operator
This practice covers the following topics:
• Creating a mapping, LOAD_CONTACT, that uses the subquery filter and the Lookup operator. – The scenario: Get all the addresses of customers who have
a high credit limit and are married. You use the Lookup operator to determine the city and the state from the address of customers.