Setting output column with a constant
You can set a constant to an output column in the Expression Builder, without mapping from the input columns. As shown below, the company column of type String is set to a fixed value, Talend.
The input data will be transformed to output data after being processed into the tMap component.
Input table:
employee_id | name |
1 | Elisa |
2 | Nicolas |
3 | Patrick |
Output table:
employee_id | name | company |
1 | Elisa | Talend |
2 | Nicolas | Talend |
3 | Patrick | Talend |
The data type of the value in the Expression Builder should be consistent with the data type of the output column. Otherwise, it will throw a Java compilation error. For example, if a constant 1 is set for company column in the Expression Builder, it will throw a compilation error when the Job is executed: Type mismatch: cannot convert from int to String, because the data type of the company column is defined as type String, but an Integer/int value is set for this column.