<< Click to Display Table of Contents >> ETL > 14.0 > Implementation Guide > Tutorial and implementation guide > Steps > Mapping Single column |
Simple mapping takes a source column and produces another column with a given target name.
The full syntax for the simple mapping is
"target-column-name": {
"column": "required-source-column-name"
}
or
"target-column-name": {
"column": "source-column-name",
"type": "sql-type"
}
If type is omitted, the type of the column is inferred from the usage (either from parent table, or from the actual value type like string, number etc.).
You should specify the type if:
•The column in the target table should have a specific type or length - for example varchar(100) and not varchar(max)
•The column in the source table should be cast to another type - for example to treat integer as string etc.
However, if the source type is sufficient, it is possible to use a shorter syntax for the column mapping:
"target-column-name": "source-column-name"
The names of target columns must be unique. The names of source columns do not have to be unique.
The columns that you do not define will not be written in the target table, unless you instruct the ETL engine to do otherwise by setting the value of mapRemaining to true.
Given the following table SourceTable:
Name |
Surname |
Age |
---|---|---|
Marcin |
Otorowski |
34 |
John |
Smith |
51 |
Kate |
Binks |
25 |
And the following JSON step definition:
{
"id": 1,
"type": "map",
"name": "Example of simple columns",
"source": "SourceTable",
"columns": {
"FirstName": "Name",
"LastName": "Surname",
"Age": "Age",
},
"target": "TargetTable_SimpleColumns"
}
The following result table TargetTable_SimpleColumns is expected:
FirstName |
LastName |
Age |
---|---|---|
John |
Smith |
30 |
Marcin |
Otorowski |
34 |
Kate |
Binks |
25 |
Using the type property lets you define a custom cast or custom type length. This common property is available for all column types, see more information in chapter Arbitrary column types.
It is possible to define a custom value returned, if the source column does not exist in the table. For more information about the usage of fallback values, see the Fallback columns chapter.