Wednesday, April 16, 2014

LOOKUP TRANSFORMATION

  • Passive Transformation
  • Can be Connected or Unconnected. Dynamic lookup is connected.
  • Use a Lookup transformation in a mapping to look up data in a flat file or a relational table, view, or synonym.
  • We can import a lookup definition from any flat file or relational database to which both the PowerCenter Client and Server can connect.
  • We can use multiple Lookup transformations in a mapping.
The Power Center Server queries the lookup source based on the lookup ports in the transformation. It compares Lookup transformation port values to lookup source column values based on the lookup condition. Pass the result of the lookup to other transformations and a target.
We can use the Lookup transformation to perform following:
  • Get a related value: EMP has DEPTNO but DNAME is not there. We use Lookup to get DNAME from DEPT table based on Lookup Condition.
  • Perform a calculation: We want only those Employees who’s SAL > Average (SAL). We will write Lookup Override query.
  • Update slowly changing dimension tables: Most important use. We can use a Lookup transformation to determine whether rows already exist in the target.
1. LOOKUP TYPES
We can configure the Lookup transformation to perform the following types of lookups:
  • Connected or Unconnected
  • Relational or Flat File
  • Cached or Un cached
Relational Lookup:
When we create a Lookup transformation using a relational table as a lookup source, we can connect to the lookup source using ODBC and import the table definition as the structure for the Lookup transformation.
  • We can override the default SQL statement if we want to add a WHERE clause or query multiple tables.
  • We can use a dynamic lookup cache with relational lookups.
Flat File Lookup:
When we use a flat file for a lookup source, we can use any flat file definition in the repository, or we can import it. When we import a flat file lookup source, the Designer invokes the Flat File Wizard.
Cached or Un cached Lookup:
We can check the option in Properties Tab to Cache to lookup or not. By default, lookup is cached.
Connected and Unconnected Lookup
Connected Lookup
Unconnected Lookup
Receives input values directly from the pipeline.
Receives input values from the result of a :LKP expression in another transformation.
We can use a dynamic or static cache.
We can use a static cache.
Cache includes all lookup columns used in the mapping.
Cache includes all lookup/output ports in the lookup condition and the lookup/return port.
If there is no match for the lookup condition, the Power Center Server returns the default value for all output ports.
If there is no match for the lookup condition, the Power Center Server returns NULL.
If there is a match for the lookup condition, the Power Center Server returns the result of the lookup condition for all lookup/output ports.
If there is a match for the lookup condition,the Power Center Server returns the result of the lookup condition into the return port.
Pass multiple output values to another transformation.
Pass one output value to another transformation.
Supports user-defined default values
Does not support user-defined default values.

clip_image053
2 .LOOKUP T/F COMPONENTS
Define the following components when we configure a Lookup transformation in a mapping:
  • Lookup source
  • Ports
  • Properties
  • Condition
1. Lookup Source:
We can use a flat file or a relational table for a lookup source. When we create a Lookup t/f, we can import the lookup source from the following locations:
  • Any relational source or target definition in the repository
  • Any flat file source or target definition in the repository
  • Any table or file that both the Power Center Server and Client machine can connect to The lookup table can be a single table, or we can join multiple tables in the same database using a lookup SQL override in Properties Tab.
2. Ports:
Ports
Lookup
Type

Number
Needed
Description

I
Connected
Unconnected
Minimum 1
Input port to Lookup. Usually ports used for Join condition are Input ports.
O
Connected
Unconnected
Minimum 1
Ports going to another transformation from Lookup.
L
Connected
Unconnected
Minimum 1
Lookup port. The Designer automatically Designates each column in the lookup source as a lookup (L) and output port (O).
RUnconnected1 Only
Return port. Use only in unconnected Lookup t/f only.

3. Properties Tab
Options
Lookup Type

Description
Lookup SQL Override
Relational
Overrides the default SQL statement to query the lookup table.
Lookup Table Name
Relational
Specifies the name of the table from which the transformation looks up and caches values.
Lookup Caching Enabled
Flat File, Relational
Indicates whether the Power Center Server caches lookup values during the session.
Lookup Policy on Multiple Match
Flat File, Relational
Determines what happens when the Lookup transformation finds multiple rows that match the lookup condition. Options: Use First Value or Use Last Value or Use Any Value or Report Error
Lookup Condition
Flat File, Relational
Displays the lookup condition you set in the Condition tab.
Connection Information
Relational
Specifies the database containing the lookup table.
Source Type
Flat File, Relational
Lookup is from a database or flat file.
Lookup Cache Directory Name
Flat File, Relational
Location where cache is build.
Lookup Cache Persistent
Flat File, Relational
Whether to use Persistent Cache or not.
Dynamic Lookup Cache
Flat File, Relational
Whether to use Dynamic Cache or not.
Recache From Lookup Source
Flat File, Relational
To rebuild cache if cache source changes and we are using Persistent Cache.
Insert Else Update
Relational
Use only with dynamic caching enabled. Applies to rows entering the Lookup transformation with the row type of insert.
Lookup Data Cache Size
Flat File, Relational
Data Cache Size
Lookup Index Cache Size
Flat File, Relational
Index Cache Size
Cache File Name Prefix
Flat File, Relational
Use only with persistent lookup cache. Specifies the file name prefix to use with persistent lookup cache files.


Some other properties for Flat Files are:
  • Date time Format
  • Thousand Separator
  • Decimal Separator
  • Case-Sensitive String Comparison
  • Null Ordering
  • Sorted Input
4: Condition Tab
We enter the Lookup Condition. The Power Center Server uses the lookup condition to test incoming values. We compare transformation input values with values in the lookup source or cache, represented by lookup ports.
  • The data types in a condition must match.
  • When we enter multiple conditions, the Power Center Server evaluates each condition as an AND, not an OR.
  • The Power Center Server matches null values.
  • The input value must meet all conditions for the lookup to return a value.
  • =, >, <, >=, <=, != Operators can be used.
  • Example: IN_DEPTNO = DEPTNO
In_DNAME = 'DELHI'
Tip: If we include more than one lookup condition, place the conditions with an equal sign first to optimize lookup performance.
Note:
1. We can use = operator in case of Dynamic Cache.
2. The Power Center Server fails the session when it encounters multiple keys for a Lookup transformation configured to use a dynamic cache.
clip_image131clip_image133
3. Connected Lookup Transformation
Example: To create a connected Lookup Transformation
  • EMP will be source table. DEPT will be LOOKUP table.
  • Create a target table CONN_Lookup_EXAMPLE in target designer. Table should contain all ports of EMP table plus DNAME and LOC as shown below.
  • Create the shortcuts in your folder.
Creating Mapping:
1. Open folder where we want to create the mapping.
2. Click Tools -> Mapping Designer.
3. Click Mapping-> Create-> Give name. Ex: m_CONN_LOOKUP_EXAMPLE
4. Drag EMP and Target table.
5. Connect all fields from SQ_EMP to target except DNAME and LOC.
6. Transformation-> Create -> Select LOOKUP from list. Give name and click
Create.
7. The Following screen is displayed.
8. As DEPT is the Source definition, click Source and then Select DEPT.
9. Click Ok.
clip_image135
10. Now Pass DEPTNO from SQ_EMP to this Lookup. DEPTNO from SQ_EMP will be named as DEPTNO1. Edit Lookup and rename it to IN_DEPTNO in ports tab.
11. Now go to CONDITION tab and add CONDITION.
DEPTNO = IN_DEPTNO and Click Apply and then OK.
Link the mapping as shown below:
12. We are not passing IN_DEPTNO and DEPTNO to any other transformation from LOOKUP; we can edit the lookup transformation and remove the OUTPUT check from them.
13. Mapping -> Validate
14. Repository -> Save
  • Create Session and Workflow as described earlier. Run the workflow and see the data in target table.
  • Make sure to give connection information for all tables.
  • Make sure to give connection for LOOKUP Table also.
We use Connected Lookup when we need to return more than one column from Lookup table.There is no use of Return Port in Connected Lookup.
SEE PROPERTY TAB FOR ADVANCED SETTINGS
clip_image137
4. Unconnected Lookup Transformation
An unconnected Lookup transformation is separate from the pipeline in the mapping. We write an expression using the :LKP reference qualifier to call the lookup within another transformation.
Steps to configure Unconnected Lookup:
  1. Add input ports.
  2. Add the lookup condition.
  3. Designate a return value.
  4. Call the lookup from another transformation.
Example: To create a unconnected Lookup Transformation
  • EMP will be source table. DEPT will be LOOKUP table.
  • Create a target table UNCONN_Lookup_EXAMPLE in target designer. Table should contain all ports of EMP table plus DNAME as shown below.
  • Create the shortcuts in your folder.
Creating Mapping:
1. Open folder where we want to create the mapping.
2. Click Tools -> Mapping Designer.
3. Click Mapping-> Create-> Give name. Ex: m_UNCONN_LOOKUP_EXAMPLE
4. Drag EMP and Target table.
5. Now Transformation-> Create -> Select EXPRESSION from list. Give name
and click Create. Then Click Done.
6. Pass all ports from SQ_EMP to EXPRESSION transformation.
7. Connect all fields from EXPRESSION to target except DNAME.
8. Transformation-> Create -> Select LOOKUP from list. Give name and click
Create.
9. Follow the steps as in Connected above to create Lookup on DEPT table.
10. Click Ok.
11. Now Edit the Lookup Transformation. Go to Ports tab.
12. As DEPTNO is common in source and Lookup, create a port IN_DEPTNO
ports tab. Make it Input port only and Give Datatype same as DEPTNO.
13. Designate DNAME as Return Port. Check on R to make it.
clip_image139clip_image141
14. Now add a condition in Condition Tab.
DEPTNO = IN_DEPTNO and Click Apply and then OK.
15. Now we need to call this Lookup from Expression Transformation.
16. Edit Expression t/f and create a new output port out_DNAME of data type as DNAME. Open the Expression editor and call Lookup as given below:
We double click Unconn in bottom of Functions tab and as we need only
DEPTNO, we pass only DEPTNO as input.
17. Validate the call in Expression editor and Click OK.
18. Mapping -> Validate
19. Repository Save.
  • Create Session and Workflow as described earlier. Run the workflow and see the data in target table.
  • Make sure to give connection information for all tables.
  • Make sure to give connection for LOOKUP Table also.
5. Lookup Caches
We can configure a Lookup transformation to cache the lookup table. The Integration Service (IS) builds a cache in memory when it processes the first row of data in a cached Lookup transformation.
The Integration Service also creates cache files by default in the $PMCacheDir. If the data does not fit in the memory cache, the IS stores the overflow values in the cache files. When session completes, IS releases cache memory and deletes the cache files.
  • If we use a flat file lookup, the IS always caches the lookup source.
  • We set the Cache type in Lookup Properties.
Lookup Cache Files
1. Lookup Index Cache:
  • Stores data for the columns used in the lookup condition.
2. Lookup Data Cache:
  • For a connected Lookup transformation, stores data for the connected output ports, not including ports used in the lookup condition.
  • For an unconnected Lookup transformation, stores data from the return port.
Types of Lookup Caches:
1. Static Cache
By default, the IS creates a static cache. It caches the lookup file or table and Looks up values in the cache for each row that comes into the transformation.The IS does not update the cache while it processes the Lookup transformation.
2. Dynamic Cache
To cache a target table or flat file source and insert new rows or update existing rows in the cache, use a Lookup transformation with a dynamic cache.
The IS dynamically inserts or updates data in the lookup cache and passes data to the target. Target table is also our lookup table. No good for performance if table is huge.
3. Persistent Cache
If the lookup table does not change between sessions, we can configure the Lookup transformation to use a persistent lookup cache.
The IS saves and reuses cache files from session to session, eliminating the time Required to read the lookup table.
4. Recache from Source
If the persistent cache is not synchronized with the lookup table, we can Configure the Lookup transformation to rebuild the lookup cache.If Lookup table has changed, we can use this to rebuild the lookup cache.
clip_image143clip_image145
5. Shared Cache
  •  Unnamed cache: When Lookup transformations in a mapping have compatible caching structures, the IS shares the cache by default. You can only share static unnamed caches.
  •  Named cache: Use a persistent named cache when we want to share a cache file across mappings or share a dynamic and a static cache. The caching structures must match or be compatible with a named cache. You can share static and dynamic named caches.
Building Connected Lookup Caches
We can configure the session to build caches sequentially or concurrently.
  • When we build sequential caches, the IS creates caches as the source rows enter the Lookup transformation.
  • When we configure the session to build concurrent caches, the IS does not wait for the first row to enter the Lookup transformation before it creates caches. Instead, it builds multiple caches concurrently.
1. Building Lookup Caches Sequentially:
clip_image002
2. Building Lookup Caches Concurrently:
clip_image002[6]
  • To configure the session to create concurrent caches
Edit Session -> In Config Object Tab-> Additional Concurrent Pipelines for
Lookup Cache Creation -> Give a value here (Auto By Default)
Note: The IS builds caches for unconnected Lookups sequentially only.

UNION TRANSFORMATION

  • Active and Connected transformation.
Union transformation is a multiple input group transformation that you can use to merge data from multiple pipelines or pipeline branches into one pipeline branch. It merges data from multiple sources similar to the UNION ALL SQL statement to Combine the results from two or more SQL statements.
Union Transformation Rules and Guidelines
  • we can create multiple input groups, but only one output group.
  • we can connect heterogeneous sources to a Union transformation.
  • all input groups and the output group must have matching ports. The Precision, data type, and scale must be identical across all groups.
  • The Union transformation does not remove duplicate rows. To remove Duplicate rows, we must add another transformation such as a Router or Filter Transformation.
  • we cannot use a Sequence Generator or Update Strategy transformation upstream from a Union transformation.
Union Transformation Components
When we configure a Union transformation, define the following components:
Transformation tab: We can rename the transformation and add a description.
Properties tab: We can specify the tracing level.
Groups tab: We can create and delete input groups. The Designer displays groups we create on the Ports tab.
Group Ports tab: We can create and delete ports for the input groups. The Designer displays ports we create on the Ports tab.
We cannot modify the Ports, Initialization Properties, Metadata Extensions, or Port Attribute Definitions tabs in a Union transformation.
Create input groups on the Groups tab, and create ports on the Group Ports tab. We can create one or more input groups on the Groups tab. The Designer creates one output group by default. We cannot edit or delete the default output group.
Example: to combine data of tables EMP_10, EMP_20 and EMP_REST
  • Import tables EMP_10, EMP_20 and EMP_REST in shared folder in Sources.
  • Create a target table EMP_UNION_EXAMPLE in target designer. Structure should be same EMP table.
  • Create the shortcuts in your folder.
clip_image002
Creating Mapping:
  1. Open folder where we want to create the mapping.
  2. Click Tools -> Mapping Designer.
  3. Click Mapping-> Create-> Give mapping name. Ex: m_union_example
  4. Drag EMP_10, EMP_20 and EMP_REST from source in mapping.
  5. Click Transformation -> Create -> Select Union from list. Give name and click Create. Now click done.
  6. Pass ports from SQ_EMP_10 to Union Transformation.
  7. Edit Union Transformation. Go to Groups Tab
  8. One group will be already there as we dragged ports from SQ_DEPT_10 to Union Transformation.
  9. As we have 3 source tables, we 3 need 3 input groups. Click add button to add 2 more groups. See Sample Mapping
  10. We can also modify ports in ports tab.
  11. Click Apply -> Ok.
  12. Drag target table now.
  13. Connect the output ports from Union to target table.
  14. Click Mapping -> Validate
  15. Repository -> Save
  • Create Session and Workflow as described earlier. Run the Workflow and see the data in target table.
  • Make sure to give connection information for all 3 source Tables.
clip_image002[5]

AGGREGATOR TRANSFORMATION

  • Connected and Active Transformation
  • The Aggregator transformation allows us to perform aggregate calculations, such as averages and sums.
  • Aggregator transformation allows us to perform calculations on groups.
Components of the Aggregator Transformation
  1. Aggregate expression
  2. Group by port
  3. Sorted Input
  4. Aggregate cache
1) Aggregate Expressions
  • Entered in an output port.
  • Can include non-aggregate expressions and conditional clauses.
The transformation language includes the following aggregate functions:
  • AVG, COUNT, MAX, MIN, SUM
  • FIRST, LAST
  • MEDIAN, PERCENTILE, STDDEV, VARIANCE
Single Level Aggregate Function: MAX(SAL)
Nested Aggregate Function: MAX( COUNT( ITEM ))
Nested Aggregate Functions
  • In Aggregator transformation, there can be multiple single level functions or multiple nested functions.
  • An Aggregator transformation cannot have both types of functions together.
  • MAX( COUNT( ITEM )) is correct.
  • MIN(MAX( COUNT( ITEM ))) is not correct. It can also include one aggregate function nested within another aggregate function
Conditional Clauses
We can use conditional clauses in the aggregate expression to reduce the number of rows used in the aggregation. The conditional clause can be any clause that evaluates to TRUE or FALSE.
  • SUM( COMMISSION, COMMISSION > QUOTA )
Non-Aggregate Functions
We can also use non-aggregate functions in the aggregate expression.
  • IIF( MAX( QUANTITY ) > 0, MAX( QUANTITY ), 0))
2) Group By Ports
  • Indicates how to create groups.
  • When grouping data, the Aggregator transformation outputs the last row of each group unless otherwise specified.
The Aggregator transformation allows us to define groups for aggregations, rather than performing the aggregation across all input data.
For example, we can find Maximum Salary for every Department.
  • In Aggregator Transformation, Open Ports tab and select Group By as needed.
3) Using Sorted Input
  • Use to improve session performance.
  • To use sorted input, we must pass data to the Aggregator transformation sorted by group by port, in ascending or descending order.
  • When we use this option, we tell Aggregator that data coming to it is already sorted.
  • We check the Sorted Input Option in Properties Tab of the transformation.
  • If the option is checked but we are not passing sorted data to the transformation, then the session fails.
4) Aggregator Caches
  • The Power Center Server stores data in the aggregate cache until it completes Aggregate calculations.
  • It stores group values in an index cache and row data in the data cache. If the Power Center Server requires more space, it stores overflow values in cache files.
Note: The Power Center Server uses memory to process an Aggregator transformation with sorted ports. It does not use cache memory. We do not need to configure cache memory for Aggregator transformations that use sorted ports.
1) Aggregator Index Cache:
The index cache holds group information from the group by ports. If we are using Group By on DEPTNO, then this cache stores values 10, 20, 30 etc.
  • All Group By Columns are in AGGREGATOR INDEX CACHE. Ex. DEPTNO
2) Aggregator Data Cache:
DATA CACHE is generally larger than the AGGREGATOR INDEX CACHE.
Columns in Data Cache:
  • Variable ports if any
  • Non group by input/output ports.
  • Non group by input ports used in non-aggregate output expression.
  • Port containing aggregate function

clip_image030
1) Example: To calculate MAX, MIN, AVG and SUM of salary of EMP table.
  • EMP will be source table.
  • Create a target table EMP_AGG_EXAMPLE in target designer. Table should contain DEPTNO, MAX_SAL, MIN_SAL, AVG_SAL and SUM_SAL
  • Create the shortcuts in your folder.
Creating Mapping:
1. Open folder where we want to create the mapping.
2. Click Tools -> Mapping Designer.
3. Click Mapping-> Create-> Give mapping name. Ex: m_agg_example
4. Drag EMP from source in mapping.
5. Click Transformation -> Create -> Select AGGREGATOR from list. Give name and click Create. Now click done.
6. Pass SAL and DEPTNO only from SQ_EMP to AGGREGATOR Transformation.
7. Edit AGGREGATOR Transformation. Go to Ports Tab
8. Create 4 output ports: OUT_MAX_SAL, OUT_MIN_SAL, OUT_AVG_SAL,
OUT_SUM_SAL
9. Open Expression Editor one by one for all output ports and give the
calculations. Ex: MAX(SAL), MIN(SAL), AVG(SAL),SUM(SAL)
10. Click Apply -> Ok.
11. Drag target table now.
12. Connect the output ports from Rank to target table.
13. Click Mapping -> Validate
14. Repository -> Save
  • Create Session and Workflow as described earlier. Run the Workflow and see the data in target table.
  • Make sure to give connection information for all tables.

SOURCE QUALIFIER TRANSFORMATION

  • Active and Connected Transformation.
  • The Source Qualifier transformation represents the rows that the Power Center Server reads when it runs a session.
  • It is only transformation that is not reusable.
  • Default transformation except in case of XML or COBOL files.
Tasks performed by Source Qualifier:
  • Join data originating from the same source database: We can join two or more tables with primary key-foreign key relationships by linking the sources to one Source Qualifier transformation.
  • Filter rows when the Power Center Server reads source data: If we Include a filter condition, the Power Center Server adds a WHERE clause to the Default query.
  • Specify an outer join rather than the default inner join: If we include a User-defined join, the Power Center Server replaces the join information Specified by the metadata in the SQL query.
  • Specify sorted ports: If we specify a number for sorted ports, the
  • Power Center Server adds an ORDER BY clause to the default SQL query.
  • Select only distinct values from the source: If we choose Select Distinct,the Power Center Server adds a SELECT DISTINCT statement to the default SQL query.
  • Create a custom query to issue a special SELECT statement for the Power Center Server to read source data: For example, you might use a Custom query to perform aggregate calculations. The entire above are possible in Properties Tab of Source Qualifier t/f.
SAMPLE MAPPING TO BE MADE:
clip_image002
clip_image004
  • Source will be EMP and DEPT tables.
  • Create target table as showed in Picture above.
  • Create shortcuts in your folder as needed.
Creating Mapping:
  1. Open folder where we want to create the mapping.
  2. Click Tools -> Mapping Designer.
  3. Click Mapping-> Create-> Give mapping name. Ex: m_SQ_example
  4. Drag EMP, DEPT, Target.
  5. Right Click SQ_EMP and Select Delete from the mapping.
  6. Right Click SQ_DEPT and Select Delete from the mapping.
  7. Click Transformation -> Create -> Select Source Qualifier from List -> Give Name -> Click Create
  8. Select EMP and DEPT both. Click OK.
  9. Link all as shown in above picture.
  10. Edit SQ -> Properties Tab -> Open User defined Join -> Give Join condition EMP.DEPTNO=DEPT.DEPTNO. Click Apply -> OK
  11. Mapping -> Validate
  12. Repository -> Save
  • Create Session and Workflow as described earlier. Run the Workflow and see the data in target table.
  • Make sure to give connection information for all tables.
SQ PROPERTIES TAB
1) SOURCE FILTER:
We can enter a source filter to reduce the number of rows the Power Center Server queries.
Note: When we enter a source filter in the session properties, we override the customized SQL query in the Source Qualifier transformation.
Steps:
  1. In the Mapping Designer, open a Source Qualifier transformation.
  2. Select the Properties tab.
  3. Click the Open button in the Source Filter field.
  4. In the SQL Editor Dialog box, enter the filter. Example: EMP.SAL)2000
  5. Click OK.
Validate the mapping. Save it. Now refresh session and save the changes. Now run the workflow and see output.
2) NUMBER OF SORTED PORTS:
When we use sorted ports, the Power Center Server adds the ports to the ORDER BY clause in the default query.
By default it is 0. If we change it to 1, then the data will be sorted by column that is at the top in SQ. Example: DEPTNO in above figure.
  • If we want to sort as per ENAME, move ENAME to top.
  • If we change it to 2, then data will be sorted by top two columns.
Steps:
  1. In the Mapping Designer, open a Source Qualifier transformation.
  2. Select the Properties tab.
  3. Enter any number instead of zero for Number of Sorted ports.
  4. Click Apply -> Click OK.
Validate the mapping. Save it. Now refresh session and save the changes. Now run the workflow and see output.
3) SELECT DISTINCT:
If we want the Power Center Server to select unique values from a source, we can use the Select Distinct option.
  • Just check the option in Properties tab to enable it.
4) PRE and POST SQL Commands
  • The Power Center Server runs pre-session SQL commands against the source database before it reads the source.
  • It runs post-session SQL commands against the source database after it writes to the target.
  • Use a semi-colon (;) to separate multiple statements.
clip_image034
5) USER DEFINED JOINS
Entering a user-defined join is similar to entering a custom SQL query. However, we only enter the contents of the WHERE clause, not the entire query.
  • We can specify equi join, left outer join and right outer join only. We Cannot specify full outer join. To use full outer join, we need to write SQL Query.
Steps:
  1. Open the Source Qualifier transformation, and click the Properties tab.
  2. Click the Open button in the User Defined Join field. The SQL Editor Dialog Box appears.
  3. Enter the syntax for the join.
  4. Click OK -> Again Ok.
Validate the mapping. Save it. Now refresh session and save the changes. Now run the workflow and see output.
Join Type
Syntax
Equi Join
DEPT.DEPTNO=EMP.DEPTNO
Left Outer Join{EMP LEFT OUTER JOIN DEPT ON DEPT.DEPTNO=EMP.DEPTNO}
Right Outer Join
{EMP RIGHT OUTER JOIN DEPT ON DEPT.DEPTNO=EMP.DEPTNO}
clip_image052clip_image054
6) SQL QUERY
For relational sources, the Power Center Server generates a query for each Source Qualifier transformation when it runs a session. The default query is a SELECT statement for each source column used in the mapping. In other words, the Power Center Server reads only the columns that are connected to another Transformation.
In mapping above, we are passing only SAL and DEPTNO from SQ_EMP to Aggregator transformation. Default query generated will be:
  • SELECT EMP.SAL, EMP.DEPTNO FROM EMP
Viewing the Default Query
  1. Open the Source Qualifier transformation, and click the Properties tab.
  2. Open SQL Query. The SQL Editor displays.
  3. Click Generate SQL.
  4. The SQL Editor displays the default query the Power Center Server uses to Select source data.
  5. Click Cancel to exit.
Note: If we do not cancel the SQL query, the Power Center Server overrides the default query with the custom SQL query.
We can enter an SQL statement supported by our source database. Before entering the query, connect all the input and output ports we want to use in the mapping.
Example: As in our case, we can’t use full outer join in user defined join, we can write SQL query for FULL OUTER JOIN:
SELECT DEPT.DEPTNO, DEPT.DNAME, DEPT.LOC, EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.SAL, EMP.COMM, EMP.DEPTNO FROM EMP FULL OUTER JOIN DEPT ON DEPT.DEPTNO=EMP.DEPTNO WHERE SAL>2000
  • We also added WHERE clause. We can enter more conditions and write More complex SQL.
We can write any query. We can join as many tables in one query as Required if all are in same database. It is very handy and used in most of the projects.
Important Points:
  • When creating a custom SQL query, the SELECT statement must list the port names in the order in which they appear in the transformation.
Example: DEPTNO is top column; DNAME is second in our SQ   mapping.
So when we write SQL Query, SELECT statement have name DNAME first, DNAME second and so on. SELECT DEPT.DEPTNO, DEPT.DNAME
  • Once we have written a custom query like above, then this query will Always be used to fetch data from database. In our example, we used WHERE SAL>2000. Now if we use Source Filter and give condition SAL) 1000 or any other, then it will not work. Informatica will always use the custom query only.
  • Make sure to test the query in database first before using it in SQL Query. If query is not running in database, then it won’t work in Informatica too.
  • Also always connect to the database and validate the SQL in SQL query editor.

Update Strategy TRANSFORMATION

  • Update Strategy Trans is an Active and Connected Transformation
Till now, we have only inserted rows in our target tables. What if we want to update, delete or reject rows coming from source based on some condition?
Example: If Address of a CUSTOMER changes, we can update the old address or keep both old and new address. One row is for old and one for new. This way we maintain the historical data.
Update Strategy is used with Lookup Transformation. In DWH, we create a Lookup on target table to determine whether a row already exists or not. Then we insert, update, delete or reject the source record as per business need.
In PowerCenter, we set the update strategy at two different levels:
  1. Within a session
  2. Within a Mapping
1. Update Strategy within a session:
When we configure a session, we can instruct the IS to either treat all rows in the same way or use instructions coded into the session mapping to flag rows for different database operations.
Session Configuration:
Edit Session -> Properties -> Treat Source Rows as: (Insert, Update, Delete, and Data Driven). Insert is default. Specifying Operations for Individual Target Tables:
clip_image002
You can set the following update strategy options:
Insert: Select this option to insert a row into a target table.
Delete: Select this option to delete a row from a table.
Update: We have the following options in this situation:
  •  Update as Update. Update each row flagged for update if it exists in the target table.
  •  Update as Insert. Inset each row flagged for update.
  •  Update else Insert. Update the row if it exists. Otherwise, insert it.
Truncate table: Select this option to truncate the target table before loading data.
2. Flagging Rows within a Mapping
Within a mapping, we use the Update Strategy transformation to flag rows for insert, delete, update, or reject.
Operation
Constant
Numeric Value
INSERT
DD_INSERT0
UPDATE
DD_UPDATE1
DELETE
DD_DELETE2
REJECT
DD_REJECT3
Update Strategy Expressions:
Frequently, the update strategy expression uses the IIF or DECODE function from the transformation language to test each row to see if it meets a particular condition.
IIF( ( ENTRY_DATE > APPLY_DATE), DD_REJECT, DD_UPDATE )
Or
IIF( ( ENTRY_DATE > APPLY_DATE), 3, 2 )
  • The above expression is written in Properties Tab of Update Strategy T/f.
  • DD means DATA DRIVEN
Forwarding Rejected Rows:
We can configure the Update Strategy transformation to either pass rejected rows to the next transformation or drop them.
Steps:
  1. Create Update Strategy Transformation
  2. Pass all ports needed to it.
  3. Set the Expression in Properties Tab.
  4. Connect to other transformations or target.
Performance tuning:
  1. Use Update Strategy transformation as less as possible in the mapping.
  2. Do not use update strategy transformation if we just want to insert into target table, instead use direct mapping, direct filtering etc.
  3. For updating or deleting rows from the target table we can use Update Strategy transformation itself.

PUSHDOWN OPTIMIZATION AND TYPES IN INFORMATICA

Pushdown optimization technique in informatica pushes the part or complete transformation logic to the source or target database. The integration service translates the transformation logic into SQL queries and sends those SQL statements to the database. Then the source or target database runs those SQL queries to process the transformation logic. 

The amount of transformation logic you can push to the database depends on the database, transformation logic, mapping and session configuration. The Integration Service processes all transformation logic that it cannot push to a database. 


To preview the SQL statements and mapping logic that the integration service pushes to the source or target database, use the pushdown optimization viewer. 

Pushdown Optimization Types: 

There are three types of pushdown optimization techniques that you can configure in a session. They are: 

  • Source-side Pushdown Optimization
  • Target-side Pushdown Optimization
  • Full Pushdown Optimization

Source-Side Pushdown Optimization: 

The Integration Service first analyses the mapping from the source to the target or until it reaches a downstream transformation that it cannot push to the source database. Then the integration service generates the SELECT statement and executes the SQL in the source database. Then it reads the result rows and process the remaining transformations. 

Target-Side Pushdown Optimization: 

The Integration Service first analyses the mapping from the target to the source or until it reaches an upstream transformation that it cannot push to the target database. Then the integration service generates the Insert, Update or Delete statements. The integration service processes the transformation logic up to the point that it can push the transformation logic to the database. Then, it executes the generated SQLs on the target database. 

Full Pushdown Optimization: 

You can use full pushdown optimization only when the source and target databases are in the same relational database management system. 

The Integration Service analyzes the mapping from the source to the target or until it reaches a downstream transformation it cannot push to the target database. If the Integration Service cannot push all transformation logic to the target database, it tries to push all transformation logic to the source database. 

If it cannot push all transformation logic to the source or target, the Integration Service pushes as much transformation logic to the source database, processes intermediate transformations that it cannot push to any database, and then pushes the remaining transformation logic to the target database. The Integration Service generates and executes an INSERT SELECT, DELETE, or UPDATE statement for each database to which it pushes transformation logic. 

Pushdown Optimization and Slowly Changing Dimensions: 

Slowly changing dimensions type 1 and type 3 logic can be pushed to the database using push down optimization technique. Use the following rules and guidelines for pushing SCD logic to database. 

  • Type 1 and type 3 SCDs can be pushed to oracle and IBM DB2 databases.
  • Source data must not have duplicate rows. The database can become deadlocked if it makes multiple updates to the same row.
  • You must create SCDs using wizard in version 8.5 or higher. SCDs created in lower version cannot be pushed to database.

When to Use Pushdown Optimization: 

Use pushdown optimization technique when the source or target database gives better performance when compared to the informatica.

Saturday, April 12, 2014

Implementing Informatica PowerCenter Session Partitioning Algorithms

Informatica PowerCenter Session Partitioning can be effectively used for parallel data processing and achieve faster data delivery. Parallel data processing performance is heavily depending on the additional hardware power available. In additional to that, it is important to choose the appropriate partitioning algorithm or partition type. In this article lets discuss the optimal session partition settings.

Business Use Case

M
Lets consider a business use case to explain the implementation of appropriate partition algorithms and configuration.
Daily sales data generated from three sales region need to be loaded into an Oracle data warehouse. The sales volume from three different regions varies a lot, hence the number of records processed for every region varies a lot. The warehouse target table is partitioned based on product line.

Below is the simple structure of the mapping to get the assumed functionality.

Pass-through Partition

A pass-through partition at the source qualifier transformation is used to split the source data into three different parallel processing data sets. Below image shows how to setup pass through partition for three different sales regions.











Once the partition is setup at the source qualifier, you get additional Source Filter option to restrict the data which corresponds to each partition. Be sure to provide the filter condition such that same data is not processed through more than one partition and data is not duplicated. Below image shows three additional Source Filters, one per each partition.

Round Robin Partition

Since the data volume from three sales region is not same, use round robin partition algorithm at the next transformation in pipeline. So that the data is equally distributed among the three partitions and the processing load is equally distributed. Round robin partition can be setup as shown in below image.



Hash Auto Key Partition

At the Aggregator transformation, data need to redistribute across the partitions to avoid the potential splitting of aggregator groups. Hash auto key partition algorithm will make sure the data from different partition is redistributed such that records with the same key is in the same partition. This algorithm will identify the keys based on the group key provided in the transformation.

Processing records of the same aggregator group in different partition will result in wrong result.  
Implementing Different Informatica PowerCenter Session Partitioning Algorithms

Key Range Partition

Use Key range partition when required to distribute the records among partitions based on the range of values of a port or multiple ports.

Here the target table is range partitioned on product line. Create a range partition on target definition on PRODUCT_LINE_ID port to get the best write throughput.
Implementing Different Informatica PowerCenter Session Partitioning AlgorithmsBelow images shows the steps involved in setting up the key range partition.

Click on Edit Keys to define the ports on which the key range partition is defined.
Implementing Different Informatica PowerCenter Session Partitioning Algorithms
A pop up window shows the list of ports in the transformation, Choose the ports  on which the key range partition is required.
Implementing Different Informatica PowerCenter Session Partitioning Algorithms
Now give the value start and end range for each partition as shown below.
Implementing Different Informatica PowerCenter Session Partitioning Algorithms
We did not have to use Hash User Key Partition and Database Partition algorithm in the use case discussed here. 

Hash User Key partition algorithm will let you choose the ports to group rows among partitions. This algorithm can be used in most of the places where hash auto key algorithm is appropriate.
Database partition algorithm queries the database system for table partition information. It reads partitioned data from the corresponding nodes in the database. This algorithm can be applied either on the source or target definition.