Showing posts with label DataStage EE. Show all posts
Showing posts with label DataStage EE. Show all posts

Saturday, August 30, 2014

How do I make the Oracle EE Stage Read Operator Run in Parallel?

Posted by Venkat ♥ Duvvuri 11:49 PM, under | 1 comment


By default the oraread operator is set to run in sequential mode. To enable parallel mode on oraread , you have to add the partition table property. This is set in the Source properties section. Then you specify the table name of this property. If more than one table is being used in the select statement, then specify only one of the tables used.

You can then specify a Partitioning Algorithm to use when partitioning the table across nodes.

It is recommend that you add the environment APT_ORAREAD_PARALLEL_ALGORITHM to the job and set its value to ROWID_HASH

APT_ORAREAD_PARALLEL_ALGORITHM

This environment variable is used to determine which partitioning algorithm to use during Oracle Enterprise parallel read operations. The algorithm defines how the stage divides the input dataset into subsets so that each parallel instance of the stage reads one subset of the data. The environment variable can be set to one of the following values:


ROUND_ROBIN - The operator divides the rows from the input dataset in a round-robin fashion using modulus function applied on the row identifier (ROWID) values of the rows within the storage blocks in which they reside

ROWID_HASH - The operator divides the rows from the input dataset in an approximately random fashion using modulus function applied on the hash codes calculated from the rowid values of the rows (recommended)

ROWID_RANGE - The operator divides the rows from the input dataset by taking into account the physical collocation of rows in the table segment and splitting the overall range of rowid values into sub-ranges. This is the default option and is a preferred option for use.

If the environment variable is not defined or is set to a value other than the values listed above, the ROWID_RANGE value is used by default.

If the ROWID_RANGE option is selected (either explicitly or implicitly) and the Oracle user does not have access to DBA_EXTENTS dictionary view, or the target table is an index-organized table (IOT) or a view, then the stage cannot use ROWID_RANGE algorithm and it automatically switches at runtime to using ROWID_HASH partitioning algorithm instead.

Article Source: IBM Support Guide

Saturday, May 10, 2014

DataStage Scenario on Finding Unique Distance from Source and Destination

Posted by Venkat ♥ Duvvuri 2:46 AM, under | 1 comment

Source,Destination,Distance
hyd,bang,1000
delhi,chennai,1500
chennai,bang,600
bang,hyd,1000
bombay,pune,1000
bang,chennai,600

**Sorted on Distance**

Source,Destination,Distance
bang,chennai,600
chennai,bang,600
bang,hyd,1000
bombay,pune,1000
hyd,bang,1000
delhi,chennai,1500

**Stg Variables**
PrevActualStr: ActualStr
ActualStr: inp.Src:inp.Dest
RevStr: inp.Dest:inp.Src
isDup: if PrevActualStr = RevStr then 1 else 0

**Constraint**
isDup = 0 [Constraint]

The below steps will explain you, How the records will be processed to o/p based on the above criteria.

Rec-1:

PrevActualStr: Garbage value
ActualStr: bangchennai
RevStr: chennaibang
isDup: 0 [if PrevActualStr = RevStr then 1 else 0]

isDup = 0 [Rec will be processed to o/p as per our constraint isDup=0]

O/P
Src Dest Distance
bang chennai 600


Rec-2:

PrevActualStr: bangchennai
ActualStr: chennaibang
RevStr: bangchennai
isDup: 1 [if PrevActualStr = RevStr then 1 else 0]

isDup = 1 [Rec willn't be processed to o/p as our constraint isDup=0]

O/P
Src Dest Distance
bang chennai 600

Rec-3

PrevActualStr: chennaibang
ActualStr: banghyd
RevStr: hydbang
isDup: 0 [if PrevActualStr = RevStr then 1 else 0]

isDup = 0

O/P
Src Dest Distance
bang chennai 600
bang hyd 1000
---------------------
====================

Thursday, February 14, 2013

How to replace a string in DataStage

Posted by Venkat ♥ Duvvuri 11:55 AM, under | 7 comments


I have seen several web sites which are explaining most of the things on DataStage, but I have not seen easiest way to replace a string by using DataStage functionality without using Ereplace Function.

Field Name: SERVICE

Requirement: If the service description contains the word "Functional", then replace the word with "Technical".

Source Service Desc: My Functional Service for you...!!!

Expected Target Service Desc: My Technical Service for you...!!!


Logic to get the output as per the specified requirement;

Saturday, January 14, 2012

New features and changes for IBM InfoSphere Information Server, Version 8.7

Posted by Venkat ♥ Duvvuri 11:09 PM, under | 6 comments

New features and changes were introduced for IBM® InfoSphere® Information Server, Version 8.7 along with documentation updates. The new and changed features and documentation updates are described in the following sections.

Table of contents

InfoSphere Information Server, Version 8.7, new features and changes:

Sunday, June 5, 2011

The tsort operator

Posted by Venkat ♥ Duvvuri 7:07 AM, under | 6 comments

Bottom

The tsort operator

WebSphere DataStage provides the sort operator, tsort that you can use to sort the records of a data set. The tsort operator can run as either a sequential or a parallel operator. The execution mode of the tsort operator determines its action:

  • Sequential mode: The tsort operator executes on a single processing node to sort an entire data set.

Sunday, April 17, 2011

How to generate Sequence Numbers in DataStage using @INROWNUM and @PARTITIONNUM System Variables

Posted by Venkat ♥ Duvvuri 1:12 AM, under | No comments


This is one of the basic requirement in DataStage, we'll have to generate sequence numbers and then assign the same values to your required O/P field (e.g. 1, 2, 3, …). If you are using the import osh operator (through a stage, e.g. the Sequential File Stage) to read external data, you can use the -recordNumberField parameter.

Solution: Generate Row Number Field with DataStage Transformer Stage

There are number of different ways to solve this problem. Here I will share with you the easiest way to generate and assign sequence numbers using a DataStage Parallel Transformer stage.

@PARTITIONNUM + @NUMPARTITIONS * (@INROWNUM - 1) + 1

Note: This logic only works if your data is evenly balanced i.e., equal number of rows going through each partition.

The above logic uses three DataStage system variables which are listed as below;

@INROWNUM – This system variable contains the row number within the partition. For each partition this variable starts from 1: 1, 2, 3, …
@NUMPARTITIONS – This system variable contains the number of partitions (1, 2, 3, …) the stage is running on.
@PARTITIONNUM – This system variable contains the number (0, 1, 2,…) of the partition that is processing the particular row.
To understand the derivation expression better, let’s see an example.

Example-1: Generating Sequence Numbers Using 2-Node Config File

2 NODE CONFIG FILE
Sample Field @INROWNUM @PARTITIONNUM @PARTITIONNUM + @NUMPARTITIONS * (@INROWNUM - 1) + 1
A 1 0 1
B 1 1 2
C 2 0 3
D 2 1 4
E 3 0 5
G 3 1 6
H 4 0 7
I 4 1 8
J 5 0 9
K 5 1 10
L 6 0 11
M 6 1 12
N 7 0 13
O 7 1 14
P 8 0 15
Q 8 1 16
R 9 0 17
S 9 1 18
T 10 0 19
U 10 1 20
V 11 0 21

Example-2: Generating Sequence Numbers Using 4-Node Config File

4 NODE CONFIG FILE
Sample Field @INROWNUM @PARTITIONNUM @PARTITIONNUM + @NUMPARTITIONS * (@INROWNUM - 1) + 1
A 1 0 1
B 1 1 2
C 1 2 3
D 1 3 4
E 2 0 5
G 2 1 6
H 2 2 7
I 2 3 8
J 3 0 9
K 3 1 10
L 3 2 11
M 3 3 12
N 4 0 13
O 4 1 14
P 4 2 15
Q 4 3 16
R 5 0 17
S 5 1 18
T 5 2 19
U 5 3 20
V 6 0 21

Wednesday, March 2, 2011

New features & changes in IBM InfoSphere Information Server 8.5

Posted by Venkat ♥ Duvvuri 7:09 PM, under | 9 comments

New features and changes were introduced in IBM® InfoSphere™ Information Server, Version 8.5 along with documentation updates. The new and changed features and documentation updates are described in the following sections.

Table of contents

InfoSphere Information Server, Version 8.5, new features and changes:

Suite and product module changes

IBM InfoSphere Business Glossary

IBM InfoSphere DataStage

Tuesday, February 8, 2011

DataStage Parallel Processing

Posted by Venkat ♥ Duvvuri 8:30 AM, under | No comments

Following figure represents one of the simplest jobs you could have — a data source,
a Transformer (conversion) stage, and the data target. The links between the stages represent the flow of data into or out of a stage. In a parallel job, each stage would normally (but not always) correspond to a process. You can have multiple instances of each process to run on the available processors in your system.


A parallel DataStage job incorporates two basic types of parallel processing — pipeline and partitioning. Both of these methods are used at runtime by the Information Server engine to execute the simple job shown in Figure 1-8. To the DataStage developer, this job would appear the same on your Designer canvas, but you can optimize it through advanced properties.

Pipeline parallelism
In the following example, all stages run concurrently, even in a single-node configuration. As data is read from the Oracle source, it is passed to the Transformer stage for transformation, where it is then passed to the DB2 target. Instead of waiting for all source data to be read, as soon as the source data stream starts to produce rows, these are passed to the subsequent stages. This method is called pipeline parallelism, and all three stages in our example operate simultaneously regardless of the degree of parallelism of the configuration file. The Information Server Engine always executes jobs with pipeline parallelism.

If you ran the example job on a system with multiple processors, the stage reading would start on one processor and start filling a pipeline with the data it had read. The transformer stage would start running as soon as there was data in the pipeline, process it and start filling another pipeline. The stage writing the transformed data to the target database would similarly start writing as soon as there was data available. Thus all three stages are operating simultaneously.


Partition parallelism
When large volumes of data are involved, you can use the power of parallel processing to your best advantage by partitioning the data into a number of separate sets, with each partition being handled by a separate instance of the job stages. Partition parallelism is accomplished at runtime, instead of a manual process that would be required by traditional systems.

The DataStage developer only needs to specify the algorithm to partition the data, not the degree of parallelism or where the job will execute. Using partition parallelism the same job would effectively be run simultaneously by several processors, each handling a separate subset of the total data. At the end of the job the data partitions can be collected back together again and written to a single data source. This is shown in following figure.


Attention: You do not need multiple processors to run in parallel. A single processor is capable of running multiple concurrent processes.


Partition parallelism [Combining pipeline and partition parallelism]
The Information Server engine combines pipeline and partition parallel processing to achieve even greater performance gains. In this scenario you would have stages processing partitioned data and filling pipelines so the next one could start on that partition before the previous one had finished. This is shown in the following figure.


In some circumstances you might want to actually re-partition your data between stages. This could happen, for example, where you want to group data differently. Suppose that you have initially processed data based on customer last name, but now you want to process on data grouped by zip code. You will have to re-partition to ensure that all customers sharing the same zip code are in the same group. DataStage allows you to re-partition between stages as and when necessary. With the Information Server engine, re-partitioning happens in memory between stages, instead of writing to disk.

Wednesday, January 26, 2011

DataStage OSH Script

Posted by Venkat ♥ Duvvuri 7:58 AM, under | No comments

The IBM InfoSphere DataStage and QualityStage Designer client creates IBM InfoSphere DataStage jobs that are compiled into parallel job flows, and reusable components that execute on the parallel Information Server engine. It allows you to use familiar graphical point-and-click techniques to develop job flows for extracting, cleansing, transforming, integrating, and loading data into target files, target systems, or packaged applications.

The Designer generates all the code. It generates the OSH (Orchestrate SHell Script) and C++ code for any Transformer stages used.
Briefly, the Designer performs the following tasks:
* Validates link requirements, mandatory stage options, transformer logic, etc.
* Generates OSH representation of data flows and stages (representations of
framework “operators”).
* Generates transform code for each Transformer stage which is then compiled
into C++ and then to corresponding native operators.
* Reusable BuildOp stages can be compiled using the Designer GUI or from
the command line.
Here is a brief primer on the OSH:
* Comment blocks introduce each operator, the order of which is determined by
the order stages were added to the canvas.
* OSH uses the familiar syntax of the UNIX shell. such as Operator name,
schema, operator options (“-name value” format), input (indicated by n< where n is the input#), and output (indicated by the n> where n is the output #).
* For every operator, input and/or output data sets are numbered sequentially
starting from zero.
* Virtual data sets (in memory native representation of data links) are
generated to connect operators.

Framework (Information Server Engine) terms and DataStage terms have equivalency. The GUI frequently uses terms from both paradigms. Runtime messages use framework terminology because the framework engine is where execution occurs. The following list shows the equivalency between framework and DataStage terms:
* Schema corresponds to table definition
* Property corresponds to format
* Type corresponds to SQL type and length
* Virtual data set corresponds to link
* Record/field corresponds to row/column
* Operator corresponds to stage

Note: The actual execution order of operators is dictated by input/output designators, and not by their placement on the diagram. The data sets connect the OSH operators. These are “virtual data sets”, that is, in memory data flows. Link names are used in data set names — it is therefore good practice to give the links meaningful names.

Sunday, January 2, 2011

DataStage Execution Flow

Posted by Venkat ♥ Duvvuri 6:50 AM, under | No comments

When you execute a job, the generated OSH and contents of the configuration file ($APT_CONFIG_FILE) is used to compose a “score”. This is similar to a SQL query optimization plan.

At runtime, IBM InfoSphere DataStage identifies the degree of parallelism and node assignments for each operator, and inserts sorts and partitioners as needed to ensure correct results. It also defines the connection topology (virtual data sets/links) between adjacent operators/stages, and inserts buffer operators to prevent deadlocks (for example, in fork-joins). It also defines the number of actual OS processes. Multiple operators/stages are combined within a single OS process as appropriate, to improve performance and optimize resource requirements.

The job score is used to fork processes with communication interconnects for data, message and control3. Processing begins after the job score and processes are created. Job processing ends when either the last row of data is processed by the final operator, a fatal error is encountered by any operator, or the job is halted by DataStage Job Control or human intervention such as DataStage Director STOP.

Job scores are divided into two sections — data sets (partitioning and collecting) and operators (node/operator mapping). Both sections identify sequential or parallel processing.


The execution (orchestra) manages control and message flow across processes and consists of the conductor node and one or more processing nodes as shown in Figure 1-6. Actual data flows from player to player — the conductor and section leader are only used to control process execution through control and message channels.

Conductor is the initial framework process. It creates the Section Leader (SL) processes (one per node), consolidates messages to the DataStage log, and manages orderly shutdown. The Conductor node has the start-up process. The Conductor also communicates with the players.

Note: You can direct the score to a job log by setting $APT_DUMP_SCORE. To identify the Score dump, look for “main program: This step....”.

Section Leader is a process that forks player processes (one per stage) and manages up/down communications. SLs communicate between the conductor and player processes only. For a given parallel configuration file, one section leader will be started for each logical node.

Players are the actual processes associated with the stages. It sends stderr and stdout to the SL, establishes connections to other players for data flow, and cleans up on completion. Each player has to be able to communicate with every other player. There are separate communication channels (pathways) for control, errors, messages and data. The data channel does not go through the section eader/conductor as this would limit scalability.

Data flows directly from upstream operator to downstream operator.

Tuesday, December 21, 2010

Data Transformations

Posted by Venkat ♥ Duvvuri 7:49 AM, under | No comments

Data transformation and movement is the process by which source data is selected, converted, and mapped to the format required by targeted systems. The process manipulates data to bring it into compliance with business, domain, and integrity rules and with other data in the target environment. Transformation can take some of the following forms:

Aggregation
Consolidating or summarizing data values into a single value. Collecting daily sales data to be aggregated to the weekly level is a common example of aggregation.

Basic conversion
Ensuring that data types are correctly converted and mapped from source to target columns.

Cleansing
Resolving inconsistencies and fixing the anomalies in source data.

Derivation
Transforming data from multiple sources by using a complex business rule or algorithm.

Enrichment
Combining data from internal or external sources to provide additional meaning to the data.

Normalizing
Reducing the amount of redundant and potentially duplicated data.
Combining
The process of combining data from multiple sources via parallel Lookup, Join, or Merge operations.

Pivoting
Converting records in an input stream to many records in the appropriate table in the data warehouse or data mart.

Sorting
Grouping related records and sequencing data based on data or string values.

Tuesday, December 7, 2010

DataStage Stages and Jobs

Posted by Venkat ♥ Duvvuri 9:48 PM, under | 1 comment

An IBM InfoSphere DataStage job consists of individual stages linked together which describe the flow of data from a data source to a data target. A stage usually has at least one data input and/or one data output. However, some stages can accept more than one data input, and output to more than one stage. Each stage has a set of predefined and editable properties that tell it how to perform or process data. Properties might include the file name for the Sequential File stage, the columns to sort, the transformations to perform, and the database table name for the DB2 stage. These properties are viewed or edited using stage editors. Stages are added to a job and linked together using the Designer. Figure shows some of the stages and their iconic representations.

Stages and links can be grouped in a shared container. Instances of the shared container can then be reused in different parallel jobs. You can also define a local container within a job — this groups stages and links into a single unit, but can only be used within the job in which it is defined. The different types of jobs have different stage types. The stages that are available in the Designer depend on the type of job that is currently open in the Designer. Parallel Job stages are organized into different groups on the Designer palette as follows:
General includes stages such as Container and Link. Data Quality includes stages such as Investigate, Standardize, Reference Match, and Survive.

Database includes stages such as Classic Federation, DB2 UDB, DB2 UDB/Enterprise, Oracle, Sybase, SQL Server®, Teradata, Distributed Transaction, and ODBC.
Development/Debug includes stages such as Peek, Sample, Head, Tail, and Row Generator.
File includes stages such as Complex Flat File, Data Set, Lookup File Set, and Sequential File.
Processing includes stages such as Aggregator, Copy, FTP, Funnel, Join, Lookup, Merge, Remove Duplicates, Slowly Changing Dimension, Surrogate Key Generator, Sort, and Transformer
Real Time includes stages such as Web Services Transformer, WebSphere MQ, and Web Services Client.
Restructure includes stages such as Column Export and Column Import.

Tuesday, November 23, 2010

DataStage Functions

Posted by Venkat ♥ Duvvuri 8:45 AM, under | No comments

Bottom
In its simplest form, IBM InfoSphere DataStage performs data transformation and movement from source systems to target systems in batch and in real time. The data sources might include indexed files, sequential files, relational databases, archives, external data sources, enterprise applications, and message queues.

DataStage manages data that arrives and data that is received on a periodic or scheduled basis. It enables companies to solve large-scale business problems with high-performance processing of massive data volumes. By leveraging the parallel processing capabilities of multiprocessor hardware platforms, DataStage can scale to satisfy the demands of ever-growing data volumes, stringent real-time requirements, and ever-shrinking batch windows.

Leveraging the combined suite of IBM Information Server, DataStage can simplify the development of authoritative master data by showing where and how information is stored across source systems. DataStage can also consolidate disparate data into a single, reliable record, cleanses and standardizes information, removes duplicates, and links records together across systems. This master record can be loaded into operational data stores, data warehouses, or master data applications such as IBM MDM using IBM InfoSphere DataStage.
IBM InfoSphere DataStage delivers four core capabilities:

* Connectivity to a wide range of mainframe, legacy, and enterprise applications, databases, file formats, and external information sources.

* Prebuilt library of more than 300 functions including data validation rules and very complex transformations.

* Maximum throughput using a parallel, high-performance processing architecture.

* Enterprise-class capabilities for development, deployment, maintenance, and high-availability. It leverages metadata for analysis and maintenance. It also operates in batch, real time, or as a Web service.

IBM InfoSphere DataStage enables an integral part of the information integration process.

Functions used in IBM InfoSphere DataStage and QualityStage


The functions that are valid in IBM® InfoSphere® DataStage® and QualityStage are also valid in IBM Information Server
FastTrack, The following is a list of functions that are generally used when defining a column derivation in a Transformer stage.
Top  | Next

Date and time functions


Bottom
The following table lists the functions that are available in the Date and Time category (Square brackets indicate an argument is optional):
Name Description Arguments Output
DateFromDaysSince Returns a date by adding an integer to a baseline date number (int32) [baseline date] date
DateFromJulianDay Returns a date from the given julian date juliandate (uint32) date
DaysSinceFromDate Returns the number of days from source date to the given date source_date

given_date

days since (int32)
HoursFromTime Returns the hour portion of a time time hours (int8)
JulianDayFromDate Returns julian day from the given date date julian date (int32)
MicroSecondsFromTime Returns the microsecond portion from a time time microseconds (int32)
MinutesFromTime Returns the minute portion from a time time minutes (int8)
MonthDayFromDate Returns the day of the month given the date date day (int8)
MonthFromDate Returns the month number given the date date month number (int8)
NextWeekdayFromDate Returns the date of the specified day of the week soonest after the source date source date

day of week (string)

date
PreviousWeekdayFromDate Returns the date of the specified day of the week most recent before the source date source date

day of week (string)

date
SecondsFromTime Returns the second portion from a time time seconds (dfloat)
SecondsSinceFromTimestamp Returns the number of seconds between two timestamps timestamp base timestamp seconds (dfloat)
TimeDate Returns the system time and date as a formatted string - system time and date (string)
TimeFromMidnightSeconds Returns the time given the number of seconds since midnight seconds (dfloat) time
TimestampFromDateTime Returns a timestamp form the given date and time date time timestamp
TimestampFromSecondsSince Returns the timestamp from the number of seconds from the base timestamp seconds (dfloat)

[base timestamp]

timestamp
TimestampFromTimet Returns a timestamp from the given unix time_t value timet (int32) timestamp
TimetFromTimestamp Returns a unix time_t value from the given timestamp timestamp timet (int32)
WeekdayFromDate Returns the day number of the week from the given date. Origin day optionally specifies the day regarded as the first in the week and is Sunday by default date [origin day] day (int8)
YeardayFromDate Returns the day number in the year from the given date date day (int16)
YearFromDate Returns the year from the given date date year (int16)
YearweekFromDate Returns the week number in the year from the given date date week (int16)
Date, Time, and Timestamp functions that specify dates, times, or timestamps in the argument use strings with specific formats: For a date, the format is %yyyy-%mm-%dd For a time, the format is %hh:%nn:%ss, or, if extended to include microseconds, %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to. For a timestamp the format is %yyyy-%mm-%dd %hh:%nn:%ss, or, if extended to include microseconds, %yyyy-%mm-%dd %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to. This applies to the arguments date, baseline date, given date, time, timestamp, and base timestamp. Functions that have days of week in the argument take a string specifying the day of the week, this applies to day of week and origin day.
Top  | Next

Logical Functions


Previous  |  Bottom
The following table lists the functions available in the Logical category (square brackets indicate an argument is optional):
Name Description Arguments Output
Not Returns the complement of the logical value of an expression expression Complement (int8)
BitAnd Returns the bitwise AND of the two integer arguments number 1 (uint64) number 2 (uint64) number (uint64)
BitOr Returns the bitwise OR of the two integer arguments number 1 (uint64) number 2 (uint64) number (uint64)
BitXOr Returns the bitwise Exclusive OR of the two integer arguments number 1 (uint64) number 2 (uint64) number (uint64)
BitExpand Returns a string containing the binary representation in "1"s and "0"s of the given integer number (uint64) string
BitCompress Returns the integer made from the string argument, which contains a binary representation of "1"s and "0"s. number (string) number (uint64)
SetBit Returns an integer with specific bits set to a specific state, where

origfield is the input value to perform the action on,

bitlist is a string containing a list of comma separated bit numbers to set the state of, and bitstate is either 1 or 0, indicating which state to set those bits.

origfield (uint64) bitlist (string)

bitstate (uint8)

number (uint64)
Top  | Next

Mathematical Functions


Previous  |  Bottom
The following table lists the functions available in the Mathematical category (square brackets indicate an argument is optional):
Name Description Arguments Output
Abs Absolute value of any numeric expression number (int32) result (dfloat)
Acos Calculates the trigonometric arc-cosine of an expression number (dfloat) result (dfloat)
Asin Calculates the trigonometric arc-sine of an expression number (dfloat) result (dfloat)
Atan Calculates the trigonometric arc-tangent of an expression number (dfloat) result (dfloat)
Ceil Calculates the smallest dfloat value greater than or equal to the given decimal value number (decimal) result (dfloat)
Cos Calculates the trigonometric cosine of an expression number (dfloat) result (dfloat)
Cosh Calculates the hyperbolic cosine of an expression number (dfloat) result (dfloat)
Div Outputs the whole part of the real division of two real numbers (dividend, divisor) dividend (dfloat) divisor (dfloat) result (dfloat)
Exp Calculates the result of base 'e' raised to the power designated by the value of the expression number (dfloat) result (dfloat)
Fabs Calculates the absolute value of the given value number (dfloat) result (dfloat)
Floor Calculates the largest dfloat value less than or equal to the given decimal value number (decimal) result (dfloat)
Ldexp Calculates a number from an exponent and mantissa mantissa (dfloat)

exponent (int32)

result (dfloat)
Llabs Returns the absolute value of the given integer number (uint64) result (int64)
Ln Calculates the natural logarithm of an expression in base 'e' number (dfloat) result (dfloat)
Log10 Returns the log to the base 10 of the given value number (dfloat) result (dfloat)
Max Returns the greater of the two argument values number 1 (int32) number 2(int32) result (int32)
Min Returns the lower of the two argument values number 1 (int32) number 2 (int32) result (int32)
Mod Calculates the modulo (the remainder) of two expressions (dividend, divisor) dividend (int32) divisor (int32) result (int32)
Neg Negate a number number (dfloat) result (dfloat)
Pwr Calculates the value of an expression when raised to a specified power (expression, power) expression (dfloat) power (dfloat) result (dfloat)
Rand Return a psuedo random integer between 0 and 232-1 - result (uint32)
Random Returns a random number between 0 232-1 - result (uint32)
Sin Calculates the trigonometric sine of an angle number (dfloat) result (dfloat)
Sinh Calculates the hyperbolic sine of an expression number (dfloat) result (dfloat)
Sqrt Calculates the square root of a number number (dfloat) result (dfloat)
Tan Calculates the trigonometric tangent of an angle number (dfloat) result (dfloat)
Tanh Calculates the hyperbolic tangent of an expression number (dfloat) result (dfloat)

Top  | Next

Null handling functions


Previous  |  Bottom
The following table lists the functions available in the Null Handling category (square brackets indicate an argument is optional):
Name Description Arguments Output
IsNotNull Returns true when an expression does not evaluate to the null value any true/false (int8)
IsNull Returns true when an expression evaluates to the null value any true/false (int8)
MakeNull Change an in-band null to out of band null any (column)

string (string)

-
NullToEmpty Returns an empty string if input column is null, otherwise returns the input column value input column input column value or empty string
NullToZero Returns zero if input column is null, otherwise returns the input column value input column input column value or zero
NullToValue Returns specified value if input column is null, otherwise returns the input column value input column, value input column value or value
SetNull Assign a null value to the target column - -
Hint: true = 1 false = 0
Top  | Next

Number functions


Previous  |  Bottom
The following table lists the functions available in the Number category (square brackets indicate an argument is optional):
Name Description Arguments Output
MantissaFromDecimal Returns the mantissa from the given decimal number (decimal) result (dfloat)
MantissaFromDFloat Returns the mantissa from the given dfloat number (dfloat) result (dfloat)
Top  | Next

Raw functions


Previous  |  Bottom
The following table lists the functions available in the Raw category (square brackets indicate an argument is optional):
Name Description Arguments Output
RawLength Returns the length of a raw string input string (raw) Result (int32)
Top  | Next

String functions


Previous  |  Bottom
The following table lists the functions available in the String category (square brackets indicate an argument is optional):
Name Description Arguments Output
AlNum Return whether the given string consists of alphanumeric characters string (string) true/false (int8)
Alpha Returns 1 if string is purely alphabetic string (string) result (int8)
CompactWhiteSpace Return the string after reducing all consective whitespace to a single space string (string) result (string)
Compare Compares two strings for sorting string1 (string)

string2 (string)

[justification (L or R)]

result (int8)
ComparNoCase Case insensitive comparison of two strings string1 (string) string2 (string) result (int8)
ComparNum Compare the first n characters of the two strings string1 (string) string2 (string)

length (int16)

result (int8)
CompareNumNoCase Caseless comparison of the first n characters of the two strings string1 (string) string2 (string)

length (int16)

result (int8)
Convert Converts specified characters in a string to designated replacement characters fromlist (string)

tolist (string)

expression (string)

result (string)
Count Count number of times a substring occurs in a string string (string)

substring (string)

result (int32)
Dcount Count number of delimited fields in a string string (string)

delimiter (string)

result (int32)
DownCase Change all uppercase letters in a string to lowercase string (string) result (string)
DQuote Enclose a string in double quotation marks string (string) result (string)
Field Return 1 or more delimited substrings string (string) delimiter (string)

occurrence (int32) [number (int32)]

result (string)
Index Find starting character position of substring string (string) substring (string) occurrence (int32) result (int32)
Left Leftmost n characters of string string (string)

number (int32)

result (string)
Len Length of string in characters string (string) result (int32)
Num Return 1 if string can be converted to a number string (string) result (int8)
PadString Return the string padded with the optional pad character and optional length string (string)

padlength (int32)

result (string)
Right Rightmost n characters of string string (string)

number (int32)

result (string)
Soundex Returns a string which identifies a set of words that are (roughly) phonetically alike based on the standard, open algorithm for SOUNDEX evaluation string (string) result (string)
Space Return a string of N space characters length (int32) result (string)
Squote Enclose a string in single quotation marks string (string) result (string)
Str Repeat a string string (string)

repeats (int32)

result (string)
StripWhiteSpace Return the string after stripping all whitespace from it string (string) result (string)
Trim Remove all leading and trailing spaces and tabs plus reduce internal occurrences to one string (string) [stripchar (string)] [options (string)] result (string)
TrimB Remove all trailing spaces and tabs string (string) result (string)
TrimF Remove all leading spaces and tabs string (string) result (string)
Trim Leading Trailing Returns a string with leading and trailing whitespace removed string (string) result (string)
Upcase Change all lowercase letters in a string to uppercase string (string) result (string)
Hint: true = 1 false = 0
Possible options for the Trim function are:
* L Removes leading occurrences of character.
* T Removes trailing occurrences of character.
* B Removes leading and trailing occurrences of character.
* R Removes leading and trailing occurrences of character, and reduces multiple occurrences to a single occurrence.
* A Removes all occurrences of character.
* F Removes leading spaces and tabs.
* E Removes trailing spaces and tabs.
* D Removes leading and trailing spaces and tabs, and reduces multiple spaces and tabs to single ones.
Top  | Next

Vector function


Previous  |  Bottom
The following function can be used within expressions to access an element in a vector column. The vector index starts at 0.
Name Description Arguments Output
ElementAt Accesses an element of a vector input column index (int) element of vector
This can be used as part of, or the whole of an expression. For example, an expression to add 1 to the third element of an vector input column 'InLink.col1' would be: ElementAt(InLink.col1, 2) + 1
Top  | Next

Type Conversion Functions


Previous  |  Bottom
The following table lists the functions available in the Type Conversion category (square brackets indicate an argument is optional):
Name Description Arguments Output
DateToString Return the string representation of the given date date

[format (string)]

result (string)
DecimalToDecimal Returns the given decimal in decimal representation with specified precision and scale decimal (decimal) [rtype (string)] [packedflag (int8)] result (decimal)
DecimalToDFloat Returns the given decimal in dfloat representation number (decimal) ["fix_zero"] result (dfloat)
DecimalToString Return the string representation of the given decimal number (decimal) ["fix_zero"] result (string)
DfloatToDecimal Returns the given dfloat in decimal representation number (dfloat) [rtype (string)] result (decimal)
DfloatToStringNoExp Returns the given dfloat in its string representation with no exponent, using the specified scale number (dfloat) scale (string) result (string)
IsValid Return whether the given string is valid for the given type. Valid types are "date", "decimal", "dfloat", "sfloat", "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", "raw", "string", "time", "timestamp". "ustring" type (string) format (string) result (int8)
StringToDate Returns a date from the given string in the given format date (string)

format (string)

date
StringToDecimal Returns the given string in decimal representation string (string) [rtype (string)] result (decimal)
StringToRaw Returns a string in raw representation string (string) result (raw)
StringToTime Returns a time representation of the given string string (string) [format (string)] time
StringToTimestamp Returns a timestamp representation of the given string string (string) [format (string)] timestamp
TimestampToDate Returns a date from the given timestamp timestamp date
TimestampToString Return the string representation of the given timestamp timestamp [format (string)] result (string)
TimestampToTime Returns the time from a given timestamp timestamp time
TimeToString Return the string representation of the given time time [format (string)] result (string)
StringToUstring Returns a ustring from the given string, optionally using the specified map (otherwise uses project default) string (string) [,mapname (string)] result (ustring)
UstringToString Returns a string from the given ustring, optionally using the specified map (otherwise uses project default) string(ustring)

[,mapname (string)]

result (string)
Rtype: The rtype argument is a string, and should contain one of the following:
* ceil: Round the source field toward positive infinity. E.g, 1.4 -> 2, -1.6 -> -1.
* floor: Round the source field toward negative infinity. E.g, 1.6 -> 1, -1.4 -> -2.
* round_inf: Round or truncate the source field toward the nearest representable value, breaking ties by rounding positive values toward positive infinity and negative values toward negative infinity. E.g, 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2.
* trunc_zero. Discard any fractional digits to the right of the rightmost fractional digit supported in the destination, regardless of sign. For example, if the destination is an integer, all fractional digits are truncated. If the destination is another decimal with a smaller scale, round or truncate to the scale size of the destination decimal. E.g, 1.6 -> 1, -1.6 -> -1.
The default is trunc_zero.
Format string: Date, Time, and Timestamp functions that take a format string (e.g., timetostring(time, stringformat)) need to have the date format specified. The format strings are described in Date and time formats. Where your dates, times, or timestamps convert to or from ustrings, InfoSphere DataStage will pick this up automatically. In these cases the separators in your format string (for example, `:' or `-') can themselves be Unicode characters.
fix_zero: By default decimal numbers comprising all zeros are treated as invalid. If the string fix_zero is specified as a second argument, then all zero decimal values are regarded as valid.
Top  | Next

Type "casting" functions


Previous  |  Bottom
There is a special class of type conversion function to help you when performing mathematical calculations using numeric fields. For example, if you have a calculation using an output column of type float derived from an input column of type integer in a Parallel Transformer stage the result will be derived as an integer regardless of its float type. If you want a non-integral result for a calculation using integral operands, you can use the following functions (which act in a similar way as casting in C) to cast the integer operands into non-integral operands:
Name Description Arguments Output
AsDouble Treat the given number as a double number (number) number (double)
AsFloat Treat the given number as a float number (number) number (float)
AsInteger Treat the given number as an integer number (number) number (int)
Top

Utility functions


Previous  |  Bottom
The following table lists the functions available in the Utility category (square brackets indicate an argument is optional):
Name Description Arguments Output
GetEnvironment Returns the value of the given environment variable environment variable (string) result (string)
NextSKChain Returns the value of the surrogate key column for the next record in the chain, or value for the newest record value (number) result (int64)
NextSurrogateKey Returns the value of the next surrogate key None result (int64)
PrevSKChain Returns the value of the surrogate key column for the previous record in the chain, or value for the first record value (number) result (int64)


Top

Friday, August 20, 2010

DW ETL Process

Posted by Venkat ♥ Duvvuri 9:19 AM, under | No comments

Extract, transform and load (ETL) is a process in database usage and especially in data warehousing that involves:

* Extracting data from outside sources
* Transforming it to fit operational needs (which can include quality levels)
* Loading it into the end target (database or data warehouse)


Extract

The first part of an ETL process involves extracting the data from the source systems.
Most data warehousing projects consolidate data from different source systems. Each separate system may also use a different data organization/format. Common data source formats are relational databases and flat files, but may include non-relational database structures such as Information Management System (IMS) or other data structures such as Virtual Storage Access Method (VSAM) or Indexed Sequential Access Method (ISAM), or even fetching from outside sources such as through web spidering or screen-scraping. The streaming of the extracted data source and load on-the-fly to the destination database is another way of performing ETL when no intermediate data storage is required. In general, the goal of the extraction phase is to convert the data into a single format which is appropriate for transformation processing.

An intrinsic part of the extraction involves the parsing of extracted data, resulting in a check if the data meets an expected pattern or structure. If not, the data may be rejected entirely or in part.

Transform

The transform stage applies a series of rules or functions to the extracted data from the source to derive the data for loading into the end target. Some data sources will require very little or even no manipulation of data. In other cases, one or more of the following transformation types may be required to meet the business and technical needs of the target database:

* Selecting only certain columns to load (or selecting null columns not to load). For example, if the source data has three columns (also called attributes) say roll_no, age and salary then the extraction may take only roll_no and salary. Similarly, the extraction mechanism may ignore all those records where salary is not present (salary = null).
* Translating coded values (e.g., if the source system stores 1 for male and 2 for female, but the warehouse stores M for male and F for female), this calls for automated data cleansing; no manual cleansing occurs during ETL
* Encoding free-form values (e.g., mapping "Male" to "1" and "Mr" to M)
* Deriving a new calculated value (e.g., sale_amount = qty * unit_price)
* Sorting
* Joining data from multiple sources (e.g., lookup, merge)
* Aggregation (for example, rollup — summarizing multiple rows of data — total sales for each store, and for each region, etc.)
* Generating surrogate-key values
* Transposing or pivoting (turning multiple columns into multiple rows or vice versa)
* Splitting a column into multiple columns (e.g., putting a comma-separated list specified as a string in one column as individual values in different columns)
* Disaggregation of repeating columns into a separate detail table (e.g., moving a series of addresses in one record into single addresses in a set of records in a linked address table)
* Lookup and validate the relevant data from tables or referential files for slowly changing dimensions.
* Applying any form of simple or complex data validation. If validation fails, it may result in a full, partial or no rejection of the data, and thus none, some or all the data is handed over to the next step, depending on the rule design and exception handling. Many of the above transformations may result in exceptions, for example, when a code translation parses an unknown code in the extracted data.

Load

The load phase loads the data into the end target, usually the data warehouse (DW). Depending on the requirements of the organization, this process varies widely. Some data warehouses may overwrite existing information with cumulative information, frequently updating extract data is done on daily, weekly or monthly basis. Other DW (or even other parts of the same DW) may add new data in a historicized form, for example, hourly. To understand this, consider a DW that is required to maintain sales records of the last year. Then, the DW will overwrite any data that is older than a year with newer data. However, the entry of data for any one year window will be made in a historicized manner. The timing and scope to replace or append are strategic design choices dependent on the time available and the business needs. More complex systems can maintain a history and audit trail of all changes to the data loaded in the DW.

As the load phase interacts with a database, the constraints defined in the database schema — as well as in triggers activated upon data load — apply (for example, uniqueness, referential integrity, mandatory fields), which also contribute to the overall data quality performance of the ETL process.

* For example, a financial institution might have information on a customer in several departments and each department might have that customer's information listed in a different way. The membership department might list the customer by name, whereas the accounting department might list the customer by number. ETL can bundle all this data and consolidate it into a uniform presentation, such as for storing in a database or data warehouse.

* Another way that companies use ETL is to move information to another application permanently. For instance, the new application might use another database vendor and most likely a very different database schema. ETL can be used to transform the data into a format suitable for the new application to use.

Real-life ETL cycle

The typical real-life ETL cycle consists of the following execution steps:

1. Cycle initiation
2. Build reference data
3. Extract (from sources)
4. Validate
5. Transform (clean, apply business rules, check for data integrity, create aggregates or disaggregates)
6. Stage (load into staging tables, if used)
7. Audit reports (for example, on compliance with business rules. Also, in case of failure, helps to diagnose/repair)
8. Publish (to target tables)
9. Archive
10. Clean up

Challenges

ETL processes can involve considerable complexity, and significant operational problems can occur with improperly designed ETL systems.

The range of data values or data quality in an operational system may exceed the expectations of designers at the time validation and transformation rules are specified. Data profiling of a source during data analysis can identify the data conditions that will need to be managed by transform rules specifications. This will lead to an amendment of validation rules explicitly and implicitly implemented in the ETL process.

Data warehouses are typically assembled from a variety of data sources with different formats and purposes. As such, ETL is a key process to bring all the data together in a standard, homogenous environment.

Design analysts should establish the scalability of an ETL system across the lifetime of its usage. This includes understanding the volumes of data that will have to be processed within service level agreements. The time available to extract from source systems may change, which may mean the same amount of data may have to be processed in less time. Some ETL systems have to scale to process terabytes of data to update data warehouses with tens of terabytes of data. Increasing volumes of data may require designs that can scale from daily batch to multiple-day microbatch to integration with message queues or real-time change-data capture for continuous transformation and update.

Performance

ETL vendors benchmark their record-systems at multiple TB (terabytes) per hour (or ~1 GB per second) using powerful servers with multiple CPUs, multiple hard drives, multiple gigabit-network connections, and lots of memory.

In real life, the slowest part of an ETL process usually occurs in the database load phase. Databases may perform slowly because they have to take care of concurrency, integrity maintenance, and indices. Thus, for better performance, it may make sense to do

* Direct Path Extract method or bulk unload whenever is possible (instead of querying the database) to reduce the load on source system while getting high speed extract
* most of the transformation processing outside of the database
* and to use bulk load operations whenever possible.

Still, even using bulk operations, database access is usually the bottleneck in the ETL process. Some common methods used to increase performance are:

* Partition tables (and indices). Try to keep partitions similar in size (watch for null values which can skew the partitioning).
* Do all validation in the ETL layer before the load. Disable integrity checking (disable constraint ...) in the target database tables during the load.
* Disable triggers (disable trigger ...) in the target database tables during the load. Simulate their effect as a separate step.
* Generate IDs in the ETL layer (not in the database).
* Drop the indices (on a table or partition) before the load - and recreate them after the load (SQL: drop index ...; create index ...).
* Use parallel bulk load when possible — works well when the table is partitioned or there are no indices. Note: attempt to do parallel loads into the same table (partition) usually causes locks — if not on the data rows, then on indices.
* If a requirement exists to do insertions, updates, or deletions, find out which rows should be processed in which way in the ETL layer, and then process these three operations in the database separately. You often can do bulk load for inserts, but updates and deletes commonly go through an API (using SQL).

Whether to do certain operations in the database or outside may involve a trade-off. For example, removing duplicates using distinct may be slow in the database; thus, it makes sense to do it outside. On the other side, if using distinct will significantly (x100) decrease the number of rows to be extracted, then it makes sense to remove duplications as early as possible in the database before unloading data.

A common source of problems in ETL is a big number of dependencies among ETL jobs. For example, job "B" cannot start while job "A" is not finished. You can usually achieve better performance by visualizing all processes on a graph, and trying to reduce the graph making maximum use of parallelism, and making "chains" of consecutive processing as short as possible. Again, partitioning of big tables and of their indices can really help.

Another common issue occurs when the data is spread between several databases, and processing is done in those databases sequentially. Sometimes database replication may be involved as a method of copying data between databases - and this can significantly slow down the whole process. The common solution is to reduce the processing graph to only three layers:

* Sources
* Central ETL layer
* Targets

This allows processing to take maximum advantage of parallel processing. For example, if you need to load data into two databases, you can run the loads in parallel (instead of loading into 1st - and then replicating into the 2nd).

Of course, sometimes processing must take place sequentially. For example, you usually need to get dimensional (reference) data before you can get and validate the rows for main "fact" tables.

Parallel processing

A recent[update] development in ETL software is the implementation of parallel processing. This has enabled a number of methods to improve overall performance of ETL processes when dealing with large volumes of data.

ETL applications implement three main types of parallelism:

* Data: By splitting a single sequential file into smaller data files to provide parallel access.
* Pipeline: Allowing the simultaneous running of several components on the same data stream. For example: looking up a value on record 1 at the same time as adding two fields on record 2.
* Component: The simultaneous running of multiple processes on different data streams in the same job, for example, sorting one input file while removing duplicates on another file.

All three types of parallelism usually operate combined in a single job.

An additional difficulty comes with making sure that the data being uploaded is relatively consistent. Because multiple source databases may have different update cycles (some may be updated every few minutes, while others may take days or weeks), an ETL system may be required to hold back certain data until all sources are synchronized. Likewise, where a warehouse may have to be reconciled to the contents in a source system or with the general ledger, establishing synchronization and reconciliation points becomes necessary.

Rerunnability, recoverability

Data warehousing procedures usually subdivide a big ETL process into smaller pieces running sequentially or in parallel. To keep track of data flows, it makes sense to tag each data row with "row_id", and tag each piece of the process with "run_id". In case of a failure, having these IDs will help to roll back and rerun the failed piece.

Best practice also calls for "checkpoints", which are states when certain phases of the process are completed. Once at a checkpoint, it is a good idea to write everything to disk, clean out some temporary files, log the state, and so on.

Best practices

Four-layered approach for ETL architecture design

* Functional layer: Core functional ETL processing (extract, transform, and load).
* Operational management layer: Job-stream definition and management, parameters, scheduling, monitoring, communication and alerting.
* Audit, balance and control (ABC) layer: Job-execution statistics, balancing and controls, rejects- and error-handling, codes management.
* Utility layer: Common components supporting all other layers.

Use file-based ETL processing where possible

* Storage costs relatively little
* Intermediate files serve multiple purposes:
o Used for testing and debugging
o Used for restart and recover processing
o Used to calculate control statistics
* Helps to reduce dependencies - enables modular programming.
* Allows flexibility for job-execution and -scheduling
* Better performance if coded properly, and can take advantage of parallel processing capabilities when the need arises.

Use data-driven methods and minimize custom ETL coding

* Parameter-driven jobs, functions, and job-control
* Code definitions and mapping in database
* Consideration for data-driven tables to support more complex code-mappings and business-rule application.

Qualities of a good ETL architecture design

* Performance
* Scalable
* Migratable
* Recoverable (run_id, ...)
* Operable (completion-codes for phases, re-running from checkpoints, etc.)
* Auditable (in two dimensions: business requirements and technical troubleshooting)

Dealing with keys

Keys are some of the most important objects in all relational databases as they tie everything together. A primary key is a column which is the identifier for a given entity, where a foreign key is a column in another table which refers a primary key.
These keys can also be made up from several columns, in which case they are composite keys. In many cases the primary key is an auto generated integer which has no meaning for the business entity being represented, but solely exists for the purpose of the relational database - commonly referred to as a surrogate key.

As there will usually be more than one datasource being loaded into the warehouse the keys are an important concern to be addressed.
Your customers might be represented in several data sources, and in one their SSN (Social Security Number) might be the primary key, their phone number in another and a surrogate in the third. All of the customers information needs to be consolidated into one dimension table.

A recommended way to deal with the concern is to add a warehouse surrogate key, which will be used as foreign key from the fact table.[1]

Usually updates will occur to a dimension's source data, which obviously must be reflected in the data warehouse.
If the primary key of the source data is required for reporting, the dimension already contains that piece of information for each row. If the source data uses a surrogate key, the ware house must keep track of it even though it is never used in queries or reports.

That is done by creating a lookup table which contains the warehouse surrogate key and the originating key [2]. This way the dimension is not polluted with surrogates from various source systems, while the ability to update is preserved.

The lookup table is used in different ways depending on the nature of the source data. There are 5 types to consider [3], where three selected ones are included here:
Type 1:
- The dimension row is simply updated to match the current state of the source system. The warehouse does not capture history. The lookup table is used to identify which dimension row to update/overwrite.
Type 2:
- A new dimension row is added with the new state of the source system. A new surrogate key is assigned. Source key is no longer unique in the lookup table.
Fully-logged:
- A new dimension row is added with the new state of the source system, while the previous dimension row is updated to reflect it is no longer active and record time of deactivation.

Work should be put in to guidance on which situations the options apply to. Is that solely a business decision?
Which factors influence the choice? The update strategy might (full wipe, incremental etc.)

Tools

Programmers can set up ETL processes using almost any programming language, but building such processes from scratch can become complex. Increasingly, companies are buying ETL tools to help in the creation of ETL processes.[citation needed]

By using an established ETL framework, one may increase one's chances of ending up with better connectivity and scalability. A good ETL tool must be able to communicate with the many different relational databases and read the various file formats used throughout an organization. ETL tools have started to migrate into Enterprise Application Integration, or even Enterprise Service Bus, systems that now cover much more than just the extraction, transformation, and loading of data. Many ETL vendors now have data profiling, data quality, and metadata capabilities.

Open-source ETL frameworks

* Apatar
* CloverETL
* Flat File Checker
* Jitterbit 2.0
* Pentaho Data Integration Kettle Project
* RapidMiner
* Scriptella
* Talend Open Studio

Proprietary ETL frameworks

* Adeptia
* IBM InfoSphere DataStage
* Informatica PowerCenter
* Oracle Data Integrator (ODI)
* Ab Initio
* Altova MapForce
* HiT Software Allora
* Digital Fuel Service Flow
* WisdomForce DatabaseSync System
* Phocas ETL
* Microsoft SQL Server Integration Services (SSIS)
* Coglin Mill RODIN Data Asset Management
* Twister Data Integrator (TDI)
* SAS Data Integration Studio
* SnapLogic Server