Samples

Pentaho Data Integration

Version
9.3.x
Audience
anonymous
Part Number
MK-95PDIA003-15
The following sample transformations demonstrate the capabilities of the Mapping step. These samples are available in the distribution package and are included at the following location: design-tools/data-integration/samples/transformations/mapping
  • Mapping: simple mapping.ktr: (an example of a sub-transformation)
  • Mapping: use simple mapping.ktr: (an example of a parent transformation)

Suppose we have a JavaScript step that we want to use multiple times in several transformations. This sample uses a simple concatenation to demonstrate mapping.Mapping Step Samples JavaScript step

The two input fields (strings) that the script needs are: leftValue and rightValue. Define these two strings in the Mapping input step:

Mapping Samples Mapping Input Specification

The calculated value res is a field we want to pass to the parent transformations, so we add a Mapping output step as well.

Note: Mapping input and output are placeholders, there is no actual logic in them.

The resulting mapping looks like the following example:

Mapping Samples Mapping Result

Now that the mapping is specified, it's ready to be run.

In this example, there are two fields coming into the Mapping step, X=A+B: A and B. A mapping is made between:

  • A and leftValue
  • B and rightValue
  • res and X the result field

This mapping is achieved with the Input and Output tabs of the Mapping dialog box, as shown in these sample screens.

Mapping Samples Input tab

In our sample, we only use one input and output mapping. It is possible however to use 0, 1 or more of either input or output mappings in a mapping transformation. That means that we need to be able to specify which input or output we're addressing in the various tabs. That is where the various step name choices come from in the screenshot.

In this sample, we checked the Main data path option. The corresponding Output tab shows the example's fieldname values in the mapping and target steps.

Mapping Samples Output tab