Changing the default data type mapping

author
Shicong Hong
EnrichVersion
6.4
6.3
6.2
6.1
6.0
5.6
EnrichProdName
Talend Big Data
Talend Open Studio for Data Integration
Talend Open Studio for MDM
Talend Open Studio for Big Data
Talend Data Fabric
Talend Open Studio for ESB
Talend Data Management Platform
Talend Big Data Platform
Talend ESB
Talend Data Integration
Talend Real-Time Big Data Platform
Talend Data Services Platform
Talend MDM Platform
task
Design and Development > Third-party systems > Processing components (Integration) > Data mapping
Data Governance > Third-party systems > Processing components (Integration) > Data mapping
Data Quality and Preparation > Third-party systems > Processing components (Integration) > Data mapping
EnrichPlatform
Talend Studio

Why changing the default data type mapping?

There are two data types in the database component schema: the Talend type and the DB type. When retrieving the table schema, there is always a default Talend type to map to the real DB type. Also, there is a default DB type to map to the Talend type on the DB schema, when linking a non-DB component to a DB output component. You can modify the default data type mapping for your project rather than changing it manually every time.

A Talend type is an intermediate Java type, mapped for each data type of different databases. These default data type mappings are configured in an XML file. Each kind of database has a separate mapping configuration file. For example, the file mapping_Mysql.xml maps MySQL data types to Talend types.

Changing the default data type mapping

To change the default data mapping, you will have to change the preferences of your project. In the portion shown below of the mapping for a MySQL database, the DB type DECIMAL will map to the Talend type Float by default when retrieving the table schema.

...
<dbToTalendTypes>
                ...
   <dbType type="DECIMAL">
                    <talendType type="id_Float" default="true" />
                    <talendType type="id_Double"/>
                    <talendType type="id_BigDecimal"/>
                    </dbType>
                ...

Procedure

  1. Open a Talend project.
  2. On the toolbar of the Studio main window, click File > Edit Project Properties from the menu bar to open the [Project Settings] dialog box.
  3. In the tree view of the dialog box, expand General and select Metadata of Talend Type to open the relevant view.
  4. Double-click the mapping_Mysql to edit the file and change the default mapping.
  5. In this example, map the DB type DECIMAL to the Talend type BigDecimal by default as follows:
    ...<dbToTalendTypes>
    ...
    <dbType type="DECIMAL">
    <talendType type="id_Float" />
    <talendType type="id_Double"/>
    <talendType type="id_BigDecimal" default="true" />
    </dbType>
    ...
  6. Click OK to save your changes.