Union mapping

<< Click to Display Table of Contents >>

ETL > 14.0 > Implementation Guide > Tutorial and implementation guide > Steps > Mapping > Advanced topics 

Union mapping

It is possible to union two or more tables, regardless of whether the number and names of columns are the same. To define more than one table during the mapping, simply use an array as a value of the source property, for example:

   {

      "id": 1,

      "type""map",

      "name""Example of union",

      "source": ["SourceTable1", "SourceTable2"],

      "columns": {

        "Name_Uppercase""Name"

      },

      "target""TargetTable_TransformedColumns",

      "mapRemaining": true

    }

 

You can also use wildcards (for example SourceTable*) to match more than one table (more information about wildcards in the following chapter: Wildcard joining).

 

The result table will have the same number of rows as all involved tables combined. The number of columns in the target table will be the same as all columns in all tables combined, minus duplicates.

 

Example

Given the following table Table1:

Name

Country

Age

Helmut

DE

20

Marcin

PL

40

and the following table Table2:

Name

Residence

Age

Helmut

DE

30

Alon

UK

50

With the following JSON file

   {

      "id": 1,

      "type""map",

      "name""Union two tables",

      "source": ["Table1", "Table2"],

      "columns": {

        "Name""Name",

        "Country""Country",

        "Residence""Residence",

        "Age""Age"

      },

      "target""Table3",

      "mapRemaining": true

    }

 

The following Table3 is produced (note that there is no de-duplication, and extra columns are added for rows which were not had them before, thus producing null values in columns Country and Residence).

Name

Country

Residence

Age

Helmut

DE

<null>

20

Marcin

PL

<null>

40

Helmut

<null>

DE

30

Alon

<null>

UK

50