Advanced Concepts in Informatica
Advanced Concepts in Informatica
MAPPING PARAMETERS
MAPPING VARIABLES
Unlike mapping parameters, mapping variables are values that can change
between sessions.
The Integration Service saves the latest value of a mapping variable to the
repository at the end of each successful session.
We can override a saved value with the parameter file.
We can also clear all saved values for the session in the Workflow Manager.
We might use a mapping variable to perform an incremental read of the source. For
example, we have a source table containing time stamped transactions and we want
to evaluate the transactions on a daily basis. Instead of manually entering a session
override to filter source data each time we run the session, we can create a
mapping variable, $$IncludeDateTime. In the source qualifier, create a filter to
read only rows whose transaction date equals $$IncludeDateTime, such as:
TIMESTAMP = $$IncludeDateTime
In the mapping, use a variable function to set the variable value to increment one
day each time the session runs. If we set the initial value of $$IncludeDateTime to
8/1/2004, the first time the Integration Service runs the session, it reads only rows
dated 8/1/2004. During the session, the Integration Service sets $
$IncludeDateTime to 8/2/2004. It saves 8/2/2004 to the repository at the end of the
session. The next time it runs the session, it reads only rows from August 2, 2004.
Expression
Filter
Router
Update Strategy
Numeric ->0
Start Value:
The start value is the value of the variable at the start of the session. The
Integration Service looks for the start value in the following order:
Current Value:
The current value is the value of the variable as the session progresses. When a
session starts, the current value of a variable is the same as the start value. The
final current value for a variable is saved to the repository at the end of a
successful session. When a session fails to complete, the Integration Service does
not update the value of the variable in the repository.
Note: If a variable function is not used to calculate the current value of a mapping
variable, the start value of the variable is saved to the repository.
Variable Data type and Aggregation Type When we declare a mapping variable in a
mapping, we need to configure the Data type and aggregation type for the variable.
The IS uses the aggregate type of a Mapping variable to determine the final current
value of the mapping variable.
Count: Integer and small integer data types are valid only.
Max: All transformation data types except binary data type are valid.
Min: All transformation data types except binary data type are valid.
Variable Functions
Variable functions determine how the Integration Service calculates the current
value of a mapping variable in a pipeline.
Creating Mapping
13. Open expression editor for TOTAL_SAL. Do the same as we did earlier for
SAL+ COMM. To add $$BONUS to it, select variable tab and select the parameter
from mapping parameter. SAL + COMM + $$Bonus
$$var_max from variable tab and SAL from ports tab as shown
below.SETMAXVARIABLE($$var_max,SAL)
17. Open Expression editor for out_min_var and write the following expression:
18. Open Expression editor for out_count_var and write the following expression:
19. Open Expression editor for out_set_var and write the following expression:
SETVARIABLE($$var_set,ADD_TO_DATE(HIREDATE,'MM',1)). Validate.
PARAMETER FILE
In the parameter file, folder and session names are case sensitive.
[Practice.ST:s_m_MP_MV_Example]
$$Bonus=1000
$$var_max=500
$$var_min=1200
$$var_count=0
We can specify the parameter file name and directory in the workflow or session
properties.
4. Enter the parameter directory and name in the Parameter Filename field.
5. Click OK.
2. Click the Properties tab and open the General Options settings.
3. Enter the parameter directory and name in the Parameter Filename field.
5. Click OK.
MAPPLETS
A mapplet is a reusable object that we create in the Mapplet Designer.
It contains a set of transformations and lets us reuse that transformation logic
in multiple mappings.
Created in Mapplet Designer in Designer Tool.
Mapplet Input:
Mapplet input can originate from a source definition and/or from an Input
transformation in the mapplet. We can create multiple pipelines in a mapplet.
Mapplet Output:
Example1: We will join EMP and DEPT table. Then calculate total salary. Give
the output to mapplet out transformation.
Steps:
PARTITIONING
A pipeline consists of a source qualifier and all the transformations and
Targets that receive data from that source qualifier.
When the Integration Service runs the session, it can achieve higher
Performance by partitioning the pipeline and performing the extract,
Transformation, and load for each partition in parallel.
PARTITIONING ATTRIBUTES
1. Partition points
2. Number of Partitions
PARTITIONING TYPES
1. Round Robin Partition Type
In round-robin partitioning, the Integration Service distributes rows of data
evenly to all partitions.
Each partition processes approximately the same number of rows.
Use round-robin partitioning when we need to distribute rows evenly and do
not need to group data among partitions.
Use database partitioning for Oracle and IBM DB2 sources and IBM DB2
targets only.
Use any number of pipeline partitions and any number of database
partitions.
We can improve performance when the number of pipeline partitions equals
the number of database partitions.
When we use database partitioning with a source qualifier with one source, the
Integration Service generates SQL queries for each database partition and
distributes the data from the database partitions among the session partitions
Equally.
For example, when a session has three partitions and the database has five
partitions, 1st and 2nd session partitions will receive data from 2 database partitions
each. Thus four DB partitions used. 3rd Session partition will receive Data from the
remaining 1 DB partition.
If the session has three partitions and the database table has two partitions, one of
the session partitions receives no data.
The Integration Service uses a hash function to group rows of data among
Partitions.
we define the number of ports to generate the partition key.
we choose the ports that define the partition key .
Suppose, you have 10 flat files of same structure. All the flat files have same
number of columns and data type. Now we need to transfer all the 10 files to same
target.
Names of files are say EMP1, EMP2 and so on.
Solution1:
1. Import one flat file definition and make the mapping as per need.
2. Now in session give the Source File name and Source File Directory location of
one file.
4. Now open session after workflow completes. Change the Filename and
Directory to give information of second file. Run workflow again.
Solution2:
1. Import one flat file definition and make the mapping as per need.
$InputFileName=EMP1.txt
6. Now edit parameter file and give value of second file. Run workflow again.
Solution3:
1. Import one flat file definition and make the mapping as per need.
2. Now make a notepad file that contains the location and name of each 10 flat
files.
Sample:
D:\EMP1.txt
E:\EMP2.txt
E:\FILES\DWH\EMP3.txt and so on
3. Now make a session and in Source file name and Source File Directory location
fields, give the name and location of above created file.
5. Click Apply.
6. Validate Session
SCD – Type 1
Slowly Changing Dimensions (SCDs) are dimensions that have data that changes
slowly, rather than changing on a time-based, regular schedule
For example, you may have a dimension in your database that tracks the sales
records of your company's salespeople. Creating sales reports seems simple
enough, until a salesperson is transferred from one regional office to another. How
do you record such a change in your sales dimension?
You could sum or average the sales by salesperson, but if you use that to compare
the performance of salesmen, that might give misleading information. If the
salesperson that was transferred used to work in a hot market where sales were
easy, and now works in a market where sales are infrequent, her totals will look
much stronger than the other salespeople in her new region, even if they are just as
good. Or you could create a second salesperson record and treat the transferred
person as a new sales person, but that creates problems also.
The Type 1 methodology overwrites old data with new data, and therefore does not
track historical data at all. This is most appropriate when correcting certain types of
data errors, such as the spelling of a name. (Assuming you won't ever need to know
how it used to be misspelled in the past.)
Here is an example of a database table that keeps supplier information:
The necessity of the lookup transformation is illustrated using the above source
and target table.
Drag all the columns from both the source and the look up transformation
and drop them all on to the Expression transformation.
Now double click on the Transformation and go to the Ports tab and create
two new columns and name it as insert and update. Both these columns are
gonna be our output data so we need to have check mark only in front of the
Output check box.
The Snap shot for the Edit transformation window is shown below.
The condition that we want to parse through our output data are listed below.
Input à IsNull(EMPNO1)
Connect the Insert column from the expression transformation to the insert
column in the first filter transformation and in the same way we are gonna
connect the update column in the expression transformation to the update
column in the second filter.
Later now connect the Empno, Ename, Sal from the expression
transformation to both filter transformation.
If there is no change in input data then filter transformation 1 forwards the
complete input to update strategy transformation 1 and same output is gonna
appear in the target table.
If there is any change in input data then filter transformation 2 forwards the
complete input to the update strategy transformation 2 then it is gonna
forward the updated input to the target table.
Go to the Properties tab on the Edit transformation
Drag the respective Empno, Ename and Sal from the filter transformations
and drop them on the respective Update Strategy Transformation.
Now go to the Properties tab and the value for the update strategy expression
is 0 (on the 1st update transformation).
Now go to the Properties tab and the value for the update strategy expression
is 1 (on the 2nd update transformation).
We are all set here finally connect the outputs of the update transformations
to the target table.
In the second Month we have one more employee added up to the table with the
Ename D and salary of the Employee is changed to the 2500 instead of 2000.
In The Target Table we are goanna add five columns (Skey, Version, Flag,
S_date ,E_Date).
The first thing that we are gonna do is to create a look up transformation and
connect the Empno from the source qualifier to the transformation.
The snapshot of choosing the Target table is shown below.
Drag the Empno column from the Source Qualifier to the Lookup
Transformation.
The Input Port for only the Empno1 should be checked.
In the Properties tab (i) Lookup table name ->Emp_Target.
Drag all the columns from both the source and the look up transformation
and drop them all on to the Expression transformation.
Now double click on the Transformation and go to the Ports tab and create
two new columns and name it as insert and update. Both these columns are
goanna be our output data so we need to have unchecked input check box.
The Snap shot for the Edit transformation window is shown below.
The condition that we want to parse through our output data are listed below.
Insert : IsNull(EmpNO1)
Filter Transformation: We need two filter transformations the purpose the first
filter is to filter out the records which we are goanna insert and the next is vice
versa.
The closer view of the connections from the expression to the filter is shown
below.
Expression Transformation:
Exp 1: It updates the target table with the skey values. Point to be noticed here is
skey gets multiplied by 100 and a new row is generated if there is any new EMP
added to the list. Else the there is no modification done on the target table.
Exp 2: If same employee is found with any updates in his records then Skey gets
added by 1 and version changes to the next higher number,F
Exp 3: If any record of in the source table gets updated then we make it only as the
output.
If change is found then we are gonna update the E_Date to S_Date.
Update Strategy: This is place from where the update instruction is set on the
target table.
102 B 2000
103 C 3000
102 B 2000 -
103 C 3000 -
103 C 3000
103 C 3000 -
Step 1: Initially in the mapping designer I’m goanna create a mapping as below.
And in this mapping I’m using lookup, expression, filter, update strategy to drive
the purpose. Explanation of each and every Transformation is given below.
Step 2: here we are goanna see the purpose and usage of all the transformations
that we have used in the above mapping.
Look up Transformation: The look Transformation looks the target table and
compares the same with the source table. Based on the Look up condition it
decides whether we need to update, insert, and delete the data from being loaded in
to the target table.
As usually we are goanna connect Empno column from the Source Qualifier
and connect it to look up transformation. Prior to this Look up
transformation has to look at the target table.
Next to this we are goanna specify the look up condition empno =empno1.
Finally specify that connection Information (Oracle) and look up policy on
multiple mismatches (use last value) in the Properties tab.
Expression Transformation:
We are using the Expression Transformation to separate out the Insert-stuff’s and
Update- Stuff’s logically.
Drag all the ports from the Source Qualifier and Look up in to Expression.
Add two Ports and Rename them as Insert, Update.
These two ports are goanna be just output ports. Specify the below
conditions in the Expression editor for the ports respectively.
Insert: isnull(ENO1 )
Filter Transformation: We are goanna use two filter Transformation to filter out
the data physically in to two separate sections one for insert and the other for the
update process to happen.
Filter 1:
Drag the Insert and other three ports which came from source qualifier in to
the Expression in to first filter.
In the Properties tab specify the Filter condition as Insert.
Filter 2:
Drag the update and other four ports which came from Look up in to the
Expression in to Second filter.
In the Properties tab specify the Filter condition as update.
Drag all the ports except the insert from the first filter in to this.
In the Properties tab specify the condition as the 0 or dd_insert.
Drag all the ports except the update from the second filter in to this.
In the Properties tab specify the condition as the 1 or dd_update.
Finally connect both the update strategy in to two instances of the target.
Step 3: Create a session for this mapping and Run the work flow.
Step 4: Observe the output it would same as the second target table
Incremental Aggregation:
When we enable the session option-> Incremental Aggregation the Integration
Service performs incremental aggregation, it passes source data through the
mapping and uses historical cache data to perform aggregation calculations
incrementally.
When using incremental aggregation, you apply captured changes in the source to
aggregate calculations in a session. If the source changes incrementally and you
can capture changes, you can configure the session to process those changes. This
allows the Integration Service to update the target incrementally, rather than
forcing it to process the entire source and recalculate the same data each time you
run the session.
For example, you might have a session using a source that receives new data every
day. You can capture those incremental changes because you have added a filter
condition to the mapping that removes pre-existing data from the flow of data. You
then enable incremental aggregation.
When the session runs with incremental aggregation enabled for the first time on
March 1, you use the entire source. This allows the Integration Service to read and
store the necessary aggregate data. On March 2, when you run the session again,
you filter out all the records except those time-stamped March 2. The Integration
Service then processes the new data and updates the target accordingly.Consider
using incremental aggregation in the following circumstances:
You can capture new source data. Use incremental aggregation when you
can capture new source data each time you run the session. Use a Stored
Procedure or Filter transformation to process new data.
Incremental changes do not significantly change the target. Use
incremental aggregation when the changes do not significantly change the
target. If processing the incrementally changed source alters more than half
the existing target, the session may not benefit from using incremental
aggregation. In this case, drop the table and recreate the target with complete
source data.
(i)The first time you run an incremental aggregation session, the Integration
Service processes the entire source. At the end of the session, the Integration
Service stores aggregate data from that session run in two files, the index file and
the data file. The Integration Service creates the files in the cache directory
specified in the Aggregator transformation properties.
(ii)Each subsequent time you run the session with incremental aggregation, you
use the incremental source changes in the session. For each input record, the
Integration Service checks historical information in the index file for a
corresponding group. If it finds a corresponding group, the Integration Service
performs the aggregate operation incrementally, using the aggregate data for that
group, and saves the incremental change. If it does not find a corresponding group,
the Integration Service creates a new group and saves the record data.
(iii)When writing to the target, the Integration Service applies the changes to the
existing target. It saves modified aggregate data in the index and data files to be
used as historical data the next time you run the session.
(iv) If the source changes significantly and you want the Integration Service to
continue saving aggregate data for future incremental changes, configure the
Integration Service to overwrite existing aggregate data with new aggregate data.
Each subsequent time you run a session with incremental aggregation, the
Integration Service creates a backup of the incremental aggregation files. The
cache directory for the Aggregator transformation must contain enough disk space
for two sets of the files.
(v)When you partition a session that uses incremental aggregation, the Integration
Service creates one set of cache files for each partition.
The Integration Service creates new aggregate data, instead of using historical data,
when you perform one of the following tasks:
When the Integration Service rebuilds incremental aggregation files, the data in the
previous files is lost.
Note: To protect the incremental aggregation files from file corruption or disk
failure, periodically back up the files.
When you use incremental aggregation, you need to configure both mapping and
session properties:
Before enabling incremental aggregation, you must capture changes in source data.
You can use a Filter or Stored Procedure transformation in the mapping to remove
pre-existing source data during a session.
Use the following guidelines when you configure the session for incremental
aggregation:
(i) Verify the location where you want to store the aggregate files.
The index and data files grow in proportion to the source data. Be sure the
cache directory has enough disk space to store historical data for the session.
When you run multiple sessions with incremental aggregation, decide where
you want the files stored. Then, enter the appropriate directory for the
process variable, $PMCacheDir, in the Workflow Manager. You can enter
session-specific directories for the index and data files. However, by using
the process variable for all sessions using incremental aggregation, you can
easily change the cache directory when necessary by changing
$PMCacheDir.
Changing the cache directory without moving the files causes the Integration
Service to reinitialize the aggregate cache and gather new aggregate data.
In a grid, Integration Services rebuild incremental aggregation files they
cannot find. When an Integration Service rebuilds incremental aggregation
files, it loses aggregate history.
Mapping Templates
Mapping Templates Overview :
Use the Informatica Stencil and the Informatica toolbar in the Mapping Architect
for Visio to create a mapping template. The Informatica Stencil contains shapes
that represent mapping objects that you can use to create a mapping template. The
Informatica toolbar contains buttons for the tasks you can perform on mapping
template.
You can create a mapping template manually, or you can create a mapping
template by importing a Power Center mapping.
2. Verify that the Informatica Stencil and Informatica toolbar are available.
3. Drag the mapping objects from the Informatica Stencil to the drawing
window:- Use the mapping objects to create visual representation of the mapping.
5. Configure link rules:- Configure rules for each link in the mapping template to
indicate how data moves from one mapping object to another. Use parameters to
make the rules flexible.
7. Declare mapping parameters and variables to use when you run sessions in
Power Center:- After you import the mappings created from the mapping
template into Power Center, you can use the mapping parameters and variables in
the session or workflow.
9. Save the mapping template:- Save changes to the mapping template drawing
file.
10. Publish the mapping template:- When you publish the mapping template,
Mapping Architect for Visio generates a mapping template XML file and a
mapping template parameter file (param.xml).If you edit the mapping template
drawing file after you publish it, you need to publish again. Do not edit the
mapping template XML file.
Note: Export the mapping XML file within the current Power Center release.
Informatica does not support imported objects from a different release.
1. Export a Power Center mapping. In the Designer, select the mapping that you
want to base the mapping template on and export it to an XML file.
3. Verify that the Informatica stencil and Informatica toolbar are available.
4. Import the mapping. On the Informatica toolbar, click the Create Template
from Mapping XML button. Mapping Architect for Visio determines the mapping
objects and links included in the mapping and adds the appropriate objects to the
drawing window.
6. Configure link rules. Configure rules for each link in the mapping template to
indicate how data moves from one mapping object to another. Use parameters to
make the rules flexible.
8. Declare mapping parameters and variables to use when you run the session
in Power Center. After you import the mappings created from the mapping
template into Power Center, you can use the mapping parameters and variables in
the session or workflow.
Note: If the Power Center mapping contains mapping parameters and variables, it
is possible that the mapping parameters and variables ($$ParameterName) may not
work for all mappings you plan to create from the mapping template. Modify or
declare new mapping parameters and variables appropriate for running the new
mappings created from the mapping template.
10. Save the mapping template. Save changes to the mapping template drawing
file.
11. Publish the mapping template. When you publish the mapping template,
Mapping Architect for Visio generates a mapping template XML file and a
mapping template parameter file (param.xml).
If you make any change to the mapping template after publishing, you need to
publish the mapping template again. Do not edit the mapping template XML file.
Note: Mapping Architect for Visio fails to create a mapping template if you import
a mapping that includes an unsupported source type, target type, or mapping
object.
Grid Processing
When a Power Center domain contains multiple nodes, you can configure
workflows and sessions to run on a grid. When you run a workflow on a grid, the
Integration Service runs a service process on each available node of the grid to
increase performance and scalability. When you run a session on a grid, the
Integration Service distributes session threads to multiple DTM processes on nodes
in the grid to increase performance and scalability.
You create the grid and configure the Integration Service in the Administration
Console. To run a workflow on a grid, you configure the workflow to run on the
Integration Service associated with the grid. To run a session on a grid, configure
the session to run on the grid.
The Integration Service distributes workflow tasks and session threads based on
how you configure the workflow or session to run:
Running workflows on a grid. The Integration Service distributes workflows
across the nodes in a grid. It also distributes the Session, Command, and
predefined Event-Wait tasks within workflows across the nodes in a grid.
Running sessions on a grid. The Integration Service distributes session
threads across nodes in a grid.
Note: To run workflows on a grid, you must have the Server grid option. To run
sessions on a grid, you must have the Session on Grid option.
When you run a workflow on a grid, the master service process runs the workflow
and all tasks except Session, Command, and predefined Event-Wait tasks, which it
may distribute to other nodes. The master service process is the Integration Service
process that runs the workflow, monitors service processes running on other nodes,
and runs the Load Balancer. The Scheduler runs on the master service process
node, so it uses the date and time for the master service process node to start
scheduled workflows.
The Load Balancer is the component of the Integration Service that dispatches
Session, Command, and predefined Event-Wait tasks to the nodes in the grid. The
Load Balancer distributes tasks based on node availability. If the Integration
Service is configured to check resources, the Load Balancer also distributes tasks
based on resource availability.
When you run a session on a grid, the master service process runs the workflow
and all tasks except Session, Command, and predefined Event-Wait tasks as it does
when you run a workflow on a grid. The Scheduler runs on the master service
process node, so it uses the date and time for the master service process node to
start scheduled workflows. In addition, the Load Balancer distributes session
threads to DTM processes running on different nodes.
When you run a session on a grid, the Load Balancer distributes session threads
based on the following factors:
Node availability :- The Load Balancer verifies which nodes are currently
running, enabled, and available for task dispatch.
Resource availability :- If the Integration Service is configured to check
resources, it identifies nodes that have resources required by mapping
objects in the session.
Partitioning configuration. The Load Balancer dispatches groups of
session threads to separate nodes based on the partitioning configuration.
You might want to configure a session to run on a grid when the workflow contains
a session that takes a long time to run.
When you run a workflow or session on a grid, service processes and DTM
processes run on different nodes. Network failures can cause connectivity loss
between processes running on separate nodes. Services may shut down
unexpectedly, or you may disable the Integration Service or service processes
while a workflow or session is running. The Integration Service failover and
recovery behavior in these situations depends on the service process that is
disabled, shuts down, or loses connectivity. Recovery behavior also depends on the
following factors:
Workflow Variables
Workflow Variables Overview:
You can create and use variables in a workflow to reference values and record
information. For example, use a Variable in a Decision task to determine whether
the previous task ran properly. If it did, you can run the next task.
If not, you can stop the workflow. Use the following types of workflow variables:
Use the following keywords to write expressions for user-defined and predefined
workflow variables:
AND
OR
NOT
TRUE
FALSE
NULL
SYSDATE
Each workflow contains a set of predefined variables that you use to evaluate
workflow and task conditions. Use the following types of predefined variables:
Sample syntax:
$s_item_summary.StartTime >
TO_DATE('11/10/2004
08:13:25')
Status Status of the previous task in the All Task Integer
workflow. Statuses include:
- ABORTED
- DISABLED
- FAILED
- NOTSTARTED
- STARTED
- STOPPED
- SUCCEEDED
Use these key words when writing
expressions to evaluate the status
of the current task.
Sample syntax:
$s_dist_loc.Status =
SUCCEEDED
TgtFailedRows Total number of rows the Session Integer
Integration Service failed to write
to the target.
Sample syntax:
$s_dist_loc.TgtFailedRows = 0
TgtSuccessRows Total number of rows successfully Session Integer
written to the target.
Sample syntax:
$s_dist_loc.TgtSuccessRows > 0
TotalTransErrors Total number of transformation Session Integer
errors.
Sample syntax:
$s_dist_loc.TotalTransErrors = 5
You can create variables within a workflow. When you create a variable in a
workflow, it is valid only in that workflow. Use the variable in tasks within that
workflow. You can edit and delete user-defined workflow variables.
Use user-defined variables when you need to make a workflow decision based on
criteria you specify. For example, you create a workflow to load data to an orders
database nightly. You also need to load a subset of this data to headquarters
periodically, every tenth time you update the local orders database. Create separate
sessions to update the local database and the one at headquarters.
Use a user-defined variable to determine when to run the session that updates the
orders database at headquarters.
3. Place a Decision task after the session that updates the local orders database.Set
up the decision condition to check to see if the number of workflow runs is evenly
divisible by 10. Use the modulus (MOD) function to do this.
5. Link the Decision task to the session that updates the database at headquarters
when the decision condition evaluates to true. Link it to the Assignment task when
the decision condition evaluates to false. When you configure workflow variables
using conditions, the session that updates the local database runs every time the
workflow runs. The session that updates the database at headquarters runs every
10th time the workflow runs.
You can create workflow variables for a workflow in the workflow properties.
3. Click Add.
4. Enter the information in the following table and click OK:
Field Description
Name Variable name. The correct format is $
$VariableName. Workflow variable names
are not case sensitive.
Do not use a single dollar sign ($) for a
user-defined workflow variable. The single
dollar sign
is reserved for predefined workflow
variables
Data type Data type of the variable. You can select
from the following data types:
- Date/Time
- Double
- Integer
- Nstring
5. To validate the default value of the new workflow variable, click the Validate
button.
6. Click Apply to save the new workflow variable.
7. Click OK.