Vous êtes sur la page 1sur 12

LOOKUP TRANSFORMATION

Passive Transformation Can be Connected or Unconnected. Dynamic lookup is connected. Use a Lookup transformation in a mapping to look up data in a flat file or a relational table, view, or synonym. We can import a lookup definition from any flat file or relational database to w ic bot t e PowerCenter Client and !erver can connect. We can use multiple Lookup transformations in a mapping. T e Power Center !erver "ueries t e lookup source based on t e lookup ports in t e transformation. #t compares Lookup transformation port values to lookup source column values based on t e lookup condition. Pass t e result of t e lookup to ot er transformations and a target. We can use the Lookup transformation to perform following: Get a related value: $%P as D$PT&' but D&(%$ is not t ere. We use Lookup to get D&(%$ from D$PT table based on Lookup Condition. Perform a calculation: We want only t ose $mployees w o)s !(L * (verage +!(L,. We will write Lookup 'verride "uery. Update slowly changing dimension tables: %ost important use. We can use a Lookup transformation to determine w et er rows already e-ist in t e target. 1. L !UP "#P$% We can configure t e Lookup transformation to perform t e following types of lookups. Connected or Unconnected /elational or 0lat 0ile Cac ed or Un cac ed &elational Lookup: W en we create a Lookup transformation using a relational table as a lookup source, we can connect to t e lookup source using 'D1C and import t e table definition as t e structure for t e Lookup transformation. We can override t e default !2L statement if we want to add a W3$/$ clause or "uery multiple tables. We can use a dynamic lookup cac e wit relational lookups. 'lat 'ile Lookup: W en we use a flat file for a lookup source, we can use any flat file definition in t e repository, or we can import it. W en we import a flat file lookup source, t e Designer invokes t e 0lat 0ile Wi4ard. (ached or Un cached Lookup:

We can c eck t e option in Properties Tab to Cac e to lookup or not. 1y default, lookup is cac ed. (onnected and Unconnected Lookup (onnected Lookup Unconnected Lookup

/eceives input /eceives input values values directly from from t e result of a .L5P t e pipeline. e-pression in anot er transformation. We can use a dynamic or static cac e. Cac e includes all lookup columns used in t e mapping. We can use a static cac e. Cac e includes all lookup6output ports in t e lookup condition and t e lookup6return port.

#f t ere is no matc #f t ere is no matc for for t e lookup t e lookup condition, t e condition, t e Power Power Center !erver Center !erver returns &ULL. returns t e default value for all output ports. #f t ere is a matc #f t ere is a matc for for t e lookup t e lookup condition,t e condition, t e Power Power Center !erver Center !erver returns t e result of t e returns t e result of lookup condition into t e t e lookup condition return port. for all lookup6output ports. Pass multiple output Pass one output value to values to anot er anot er transformation. transformation. !upports user7 defined default values Does not support user7 defined default values.

) .L !UP "*' ( +P ,$,"% Define t e following components w en we configure a Lookup transformation in a mapping. Lookup source Ports Properties Condition 1. Lookup %ource: We can use a flat file or a relational table for a lookup source. W en we create a Lookup t6f, we can import t e lookup source from t e following locations. (ny relational source or target definition in t e repository (ny flat file source or target definition in t e repository (ny table or file t at bot t e Power Center !erver and Client mac ine can connect to T e lookup table can be a single table, or we can 8oin multiple tables in t e same database using a lookup !2L override in Properties Tab. ). Ports:

Ports Lookup "ype #

,umber -escription ,eeded

Connected %inimum #nput port to Unconnected 9 Lookup. Usually ports used for :oin condition are #nput ports. Connected %inimum Ports going to Unconnected 9 anot er transformation from Lookup. Connected %inimum Lookup port. Unconnected 9 T e Designer automatically

'

Designates eac column in t e lookup source as a lookup +L, and output port +',. / Unconnected 9 'nly /eturn port. Use only in unconnected Lookup t6f only.

.. Properties "ab ptions Lookup "ype -escription 'verrides t e default !2L statement to "uery t e lookup table. !pecifies t e name of t e table from w ic t e transformation looks up and cac es values. #ndicates w et er t e Power Center !erver cac es lookup values during t e session. Determines w at appens w en t e Lookup transformation finds multiple rows t at matc t e lookup condition.

Lookup !2L /elational 'verride

Lookup Table /elational &ame

Lookup Cac ing $nabled

0lat 0ile, /elational

Lookup Policy on %ultiple %atc

0lat 0ile, /elational

'ptions. Use 0irst ;alue or Use Last ;alue or Use (ny ;alue or /eport $rror Lookup Condition 0lat 0ile, /elational Displays t e lookup condition you set in t e Condition tab. !pecifies t e database containing t e lookup table. Lookup is from a database or flat file. Location w ere cac e is build.

Connection #nformation

/elational

!ource Type 0lat 0ile, /elational Lookup Cac e Directory &ame Lookup Cac e Persistent Dynamic Lookup Cac e 0lat 0ile, /elational

0lat 0ile, /elational 0lat 0ile, /elational

W et er to use Persistent Cac e or not. W et er to use Dynamic Cac e or not. To rebuild cac e if cac e source c anges and we are using Persistent Cac e. Use only wit dynamic cac ing enabled. (pplies to rows entering t e Lookup transformation wit t e row type of insert.

/ecac e 0lat 0ile, 0rom Lookup /elational !ource

#nsert $lse Update

/elational

Lookup Data 0lat 0ile, Cac e !i4e /elational Lookup 0lat 0ile, #nde- Cac e /elational !i4e Cac e 0ile 0lat 0ile, &ame Prefi- /elational

Data Cac e !i4e #nde- Cac e !i4e

Use only wit persistent lookup cac e. !pecifies t e file name prefi- to use wit persistent lookup cac e files.

%ome other properties for 'lat 'iles are: Date time 0ormat T ousand !eparator Decimal !eparator Case7!ensitive !tring Comparison &ull 'rdering !orted #nput /: (ondition "ab We enter t e Lookup Condition. T e Power Center !erver uses t e lookup condition to test incoming values. We compare transformation input values wit values in t e lookup source or cac e, represented by lookup ports. T e data types in a condition must matc . W en we enter multiple conditions, t e Power Center !erver evaluates eac condition as an (&D, not an '/. T e Power Center !erver matc es null values. T e input value must meet all conditions for t e lookup to return a value. <, *, =, *<, =<, >< 'perators can be used. $-ample. #&?D$PT&' < D$PT&' #n?D&(%$ < @D$L3#@ Tip. #f we include more t an one lookup condition, place t e conditions wit an e"ual sign first to optimi4e lookup performance. ,ote: 9. We can use < operator in case of Dynamic Cac e. A. T e Power Center !erver fails t e session w en it encounters multiple keys for a Lookup transformation configured to use a dynamic cac e.

.. (onnected Lookup "ransformation $0ample: To create a connected Lookup Transformation $%P will be source table. D$PT will be L''5UP table. Create a target table C'&&?Lookup?$B(%PL$ in target designer. Table s ould contain all ports of $%P table plus D&(%$ and L'C as s own below. Create t e s ortcuts in your folder. (reating +apping: 9. 'pen folder w ere we want to create t e mapping. A. Click Tools 7* %apping Designer. C. Click %apping7* Create7* Dive name. $-. m?C'&&?L''5UP?$B(%PL$ E. Drag $%P and Target table. F. Connect all fields from !2?$%P to target e-cept D&(%$ and L'C. G. Transformation7* Create 7* !elect L''5UP from list. Dive name and click Create. H. T e 0ollowing screen is displayed. I. (s D$PT is t e !ource definition, click !ource and t en !elect D$PT. J. Click 'k.

9K. &ow Pass D$PT&' from !2?$%P to t is Lookup. D$PT&' from !2?$%P will be named as D$PT&'9. $dit Lookup and rename it to #&?D$PT&' in ports tab.

99. &ow go to C'&D#T#'& tab and add C'&D#T#'&. D$PT&' < #&?D$PT&' and Click (pply and t en '5. Link t e mapping as s own below. 9A. We are not passing #&?D$PT&' and D$PT&' to any ot er transformation from L''5UPL we can edit t e lookup transformation and remove t e 'UTPUT c eck from t em. 9C. %apping 7* ;alidate 9E. /epository 7* !ave Create !ession and Workflow as described earlier. /un t e workflow and see t e data in target table. %ake sure to give connection information for all tables. %ake sure to give connection for L''5UP Table also. We use Connected Lookup w en we need to return more t an one column from Lookup table.T ere is no use of /eturn Port in Connected Lookup. %$$ P& P$&"# "12 ' & 1-31,($- %$""4,G%

/. Unconnected Lookup "ransformation (n unconnected Lookup transformation is separate from t e pipeline in t e mapping. We write an e-pression using t e .L5P reference "ualifier to call t e lookup wit in anot er transformation. %teps to configure Unconnected Lookup: 9. (dd input ports. A. (dd t e lookup condition. C. Designate a return value. E. Call t e lookup from anot er transformation. $0ample: To create a unconnected Lookup Transformation $%P will be source table. D$PT will be L''5UP table. Create a target table U&C'&&?Lookup?$B(%PL$ in target designer. Table s ould contain all ports of $%P table plus D&(%$ as s own below. Create t e s ortcuts in your folder. (reating +apping: 9. 'pen folder w ere we want to create t e mapping. A. Click Tools 7* %apping Designer. C. Click %apping7* Create7* Dive name. $-. m?U&C'&&?L''5UP?$B(%PL$

E. Drag $%P and Target table. F. &ow Transformation7* Create 7* !elect $BP/$!!#'& from list. Dive name and click Create. T en Click Done. G. Pass all ports from !2?$%P to $BP/$!!#'& transformation. H. Connect all fields from $BP/$!!#'& to target e-cept D&(%$. I. Transformation7* Create 7* !elect L''5UP from list. Dive name and click Create. J. 0ollow t e steps as in Connected above to create Lookup on D$PT table. 9K. Click 'k. 99. &ow $dit t e Lookup Transformation. Do to Ports tab. 9A. (s D$PT&' is common in source and Lookup, create a port #&?D$PT&' ports tab. %ake it #nput port only and Dive Datatype same as D$PT&'. 9C. Designate D&(%$ as /eturn Port. C eck on / to make it.

9E. &ow add a condition in Condition Tab. D$PT&' < #&?D$PT&' and Click (pply and t en '5. 9F. &ow we need to call t is Lookup from $-pression Transformation. 9G. $dit $-pression t6f and create a new output port out?D&(%$ of data type as D&(%$. 'pen t e $-pression editor and call Lookup as given below. We double click Unconn in bottom of 0unctions tab and as we need only D$PT&', we pass only D$PT&' as input. 9H. ;alidate t e call in $-pression editor and Click '5. 9I. %apping 7* ;alidate 9J. /epository !ave.

Create !ession and Workflow as described earlier. /un t e workflow and see t e data in target table. %ake sure to give connection information for all tables. %ake sure to give connection for L''5UP Table also. 5. Lookup (aches We can configure a Lookup transformation to cac e t e lookup table. T e #ntegration !ervice +#!, builds a cac e in memory w en it processes t e first row of data in a cac ed Lookup transformation. T e #ntegration !ervice also creates cac e files by default in t e MP%Cac eDir. #f t e data does not fit in t e memory cac e, t e #! stores t e overflow values in t e cac e files. W en session completes, #! releases cac e memory and deletes t e cac e files. #f we use a flat file lookup, t e #! always cac es t e lookup source. We set t e Cac e type in Lookup Properties. Lookup (ache 'iles 9. Lookup 4nde0 (ache: !tores data for t e columns used in t e lookup condition. A. Lookup -ata (ache: 0or a connected Lookup transformation, stores data for t e connected output ports, not including ports used in t e lookup condition. 0or an unconnected Lookup transformation, stores data from t e return port. "ypes of Lookup (aches: 1. %tatic (ache 1y default, t e #! creates a static cac e. #t cac es t e lookup file or table and Looks up values in t e cac e for eac row t at comes into t e transformation.T e #! does not update t e cac e w ile it processes t e Lookup transformation. ). -ynamic (ache To cac e a target table or flat file source and insert new rows or update e-isting rows in t e cac e, use a Lookup transformation wit a dynamic cac e. T e #! dynamically inserts or updates data in t e lookup cac e and passes data to t e target. Target table is also our lookup table. &o good for performance if table is uge. .. Persistent (ache #f t e lookup table does not c ange between sessions, we can configure t e Lookup transformation to use a persistent lookup cac e. T e #! saves and reuses cac e files from session to session, eliminating t e time /e"uired to read t e lookup table. /. &ecache from %ource

#f t e persistent cac e is not sync roni4ed wit t e lookup table, we can Configure t e Lookup transformation to rebuild t e lookup cac e.#f Lookup table as c anged, we can use t is to rebuild t e lookup cac e.

5. %hared (ache Unnamed cache: W en Lookup transformations in a mapping ave compatible cac ing structures, t e #! s ares t e cac e by default. Nou can only s are static unnamed cac es. ,amed cache: Use a persistent named cac e w en we want to s are a cac e file across mappings or s are a dynamic and a static cac e. T e cac ing structures must matc or be compatible wit a named cac e. Nou can s are static and dynamic named cac es. 2uilding (onnected Lookup (aches We can configure t e session to build cac es se"uentially or concurrently. W en we build se"uential cac es, t e #! creates cac es as t e source rows enter t e Lookup transformation. W en we configure t e session to build concurrent cac es, t e #! does not wait for t e first row to enter t e Lookup transformation before it creates cac es. #nstead, it builds multiple cac es concurrently. 1. 2uilding Lookup (aches %e6uentially:

). 2uilding Lookup (aches (oncurrently:

To configure t e session to create concurrent cac es

$dit !ession 7* #n Config 'b8ect Tab7* (dditional Concurrent Pipelines for Lookup Cac e Creation 7* Dive a value ere +(uto 1y Default, &ote. T e #! builds cac es for unconnected Lookups se"uentially only.

Vous aimerez peut-être aussi