Type mapping - 6.5

Talend Data Fabric Studio User Guide

EnrichVersion
6.5
EnrichProdName
Talend Data Fabric
EnrichPlatform
Talend Studio
task
Data Quality and Preparation
Design and Development

In Talend Studio, there are two data types in the database component schema: the Talend type and the database type. When retrieving the table schema, there is always a default Talend type to map to the real database type, and there is a default database type to map to the Talend type on the database schema, when linking a non-database component to a database output component.

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.

By editing the mapping file, you can modify any default data type mapping for your project rather than changing it manually every time, and add new type mappings to server your needs.

Accessing mapping files and defining type mappings

  1. On the toolbar of the Studio main window, click or click File > Edit Project Properties from the menu bar to open the [Project Settings] dialog box.

  2. In the tree view of the dialog box, expand General and select Metadata of Talend Type to open the Metadata of TalendType view, which lists the mapping files for all the database types used in Talend Studio.

    You can import, export, or delete any of the conversion files by clicking Import, Export or Remove respectively.

    You can modify any of the conversion files according to your needs by by selecting the file and clicking the Edit button to open the [Edit mapping file] dialog box and then modify the XML code directly in the open dialog box.

    Note that when you define a type mapping, you need to map both from Talend type to database type and from database type to Talend type.

    • The <dbTypes> element with its child <dbType> elements defines the supported database types. To add a new database type in the mapping file, you need to add a <dbType> element under the <dbTypes> element. The example below adds two database types BOOLEAN and YESNO.

      <dbType type="BOOLEAN" ignoreLen="true" ignorePre="true"/>
                                  <dbType type="YESNO" ignoreLen="true" ignorePre="true" />
    • The <talendToDbTypes> element with its child <talendType> elements defines a suggested database type list and the default database type when setting a Talend type for a metadata column. To map a Talend type to one or more database types, you need to add a talendType element under the <talendToDbTypes> element. The example below maps the Talend type id_Boolean to two database types BOOLEAN and YESNO.

      <talendType type="id_Boolean">	
                                  <dbType type="YESNO" default="true" />
                                  <dbType type="BOOLEAN"/>				
                                  </talendType>
    • The <dbToTalendTypes> element with its child <dbType> elements defines a suggested Talend type list and the default Talend type when retrieving schema from the database. To map a database type to one or more Talend types, you need to add a dbType element under the <dbToTalendTypes> element. The example below maps the database type YESNO to the Talend type id_Boolean.<dbType type="YESNO"> <talendType type="id_Boolean" default="true" /> </dbType>

Frequently used attributes in dbType element

Using attributes in the conversion mappings, you can define the default values or behavior of the relevant schema columns. The table below describes the frequently used attributes in the dbType element.

Attribute

Description

ignoreLen

When set to true, the length that you set for newly added columns of the type in schema (by Edit schema) on components will be ignored.

ignorePre

When set true, the precision that you set for newly added columns of the type in schema (by Edit schema) on components will be ignored.

default

When set true, the type defined in this element will be the default type of newly added columns (by Edit schema) on components.

defaultLength

Sets the default length of newly added columns of the type (by Edit schema) on components.

defaultPrecision

Sets the default precision of newly added columns of the type (by Edit schema) on components.