expression transformation overview

Upload: yprajudwh

Post on 30-May-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Expression Transformation Overview

    1/3

    Expression Transformation Overview

    Transformation type:PassiveConnected

    Use the Expression transformation to calculate values in a single row. Forexample, you might need to adjust employee salaries, concatenate first and lastnames, or convert strings to numbers. You can also use the Expressiontransformation to test conditional statements before you pass the results to atarget or other transformations.

    Use the Expression transformation to perform non-aggregate calculations. Toperform calculations involving multiple rows, such as sums or averages, use theAggregator transformation.

    Figure 5-1 shows a simple mapping with an Expression transformation used toconcatenate the first and last names of employees from the EMPLOYEES table:

  • 8/14/2019 Expression Transformation Overview

    2/3

    Expression Transformation Components

    You can create an Expression transformation in the Transformation Developer or

    the Mapping Designer.

    An Expression transformation contains the following tabs:

    Transformation. Enter the name and description of the transformation. Thenaming convention for an Expression transformation isEXP_TransformationName. You can also make the transformation reusable.Ports. Create and configure ports.Properties. Configure the tracing level to determine the amount of transactiondetail reported in the session log file.Metadata Extensions. Specify the extension name, datatype, precision, and

    value. You can also create reusable metadata extensions.

    Configuring Ports

    You can create and modify ports on the Ports tab.

    Configure the following components on the Ports tab:

    Port name. Name of the port.Datatype, precision, and scale. Configure the datatype and set the precision

    and scale for each port.Port type. A port can be input, output, input/output, or variable. The input portsreceive data and output ports pass data. The input/output ports pass dataunchanged. Variable ports store data temporarily and can store values acrossthe rows.Expression. Use the Expression Editor to enter expressions. Expressions usethe transformation language, which includes SQL-like functions, to performcalculations.Default values and description. Set default value for ports and adddescription.

    Calculating Values

    To calculate values for a single row using the Expression transformation, youmust include the following ports:

    Input or input/output ports. Provides values used in a calculation. Forexample, if you need to calculate the total price for an order, create two input orinput/output ports. One port provides the unit price and the other provides the

  • 8/14/2019 Expression Transformation Overview

    3/3

    quantity ordered.Output ports. Provides the return value of the expression. You enter theexpression as a configuration option for the output port. You can also configurea default value for each port.

    You can enter multiple expressions in a single Expression transformation bycreating an expression for each output port. For example, you might want tocalculate different types of withholding taxes from each employee paycheck,such as local and federal income tax, Social Security and Medicare. Since all ofthese calculations require the employee salary, the withholding category, andmay require the corresponding tax rate, you can create input/output ports for thesalary and withholding category and a separate output port for each calculation.

    Creating an Expression Transformation

    Use the following procedure to create an Expression transformation.

    To create an Expression transformation:

    1.In the Mapping Designer, open a mapping.2.Click Transformation > Create. Select Expression transformation.3.Enter a name and click Done.

    4.Select and drag the ports from the source qualifier or other transformations toadd to the Expression transformation.

    You can also open the transformation and create ports manually.

    5.Double-click on the title bar and click on Ports tab. You can create output andvariable ports within the transformation.

    6.In the Expression section of an output or variable port, open the ExpressionEditor.7.Enter an expression. Click Validate to verify the expression syntax.8.Click OK.

    9.Assign the port datatype, precision, and scale to match the expression returnvalue.

    10.Create reusable transformations on the Transformation tab.

    Note: After you make the transformation reusable, you cannot copy ports fromthe source qualifier or other transformations. Youcan create ports manuallywithin the transformation.

    11.Configure the tracing level on the Properties tab.12.Add metadata extensions on the Metadata Extensions tab.13.Click OK.14.Connect the output ports to a downstream transformation or target.