Accessing mapping files and defining type mappings - 7.1

Talend Big Data Studio User Guide

EnrichVersion
7.1
EnrichProdName
Talend Big Data
EnrichPlatform
Talend Studio
task
Design and Development

Procedure

  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 TalendType 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 a mapping file according to your needs 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>

    Below is the XML metadata mapping file for the Access database:

    <?xml version="1.0"?>
                            <mapping>
                            <dbms product="ACCESS" id="access_id" label="Mapping Access" default="true">
                            <dbTypes>
                            <dbType type="BIT" ignoreLen="true" ignorePre="true"/>
                            <dbType type="BOOLEAN" ignoreLen="true" ignorePre="true"/>
                            <dbType type="COUNTER"/>
                            <dbType type="DATE" ignoreLen="true" ignorePre="true"/>
                            <dbType type="DOUBLE" ignoreLen="true" ignorePre="true"/>
                            <dbType type="DECIMAL" ignoreLen="true" ignorePre="true"/>
                            <dbType type="FLOAT" ignoreLen="true" ignorePre="true"/>
                            <dbType type="INTEGER" ignoreLen="true" ignorePre="true"/>
                            <dbType type="NUMERIC" ignoreLen="true" ignorePre="true"/>
                            <dbType type="REAL" ignoreLen="true" ignorePre="true"/>
                            <dbType type="SMALLINT" ignoreLen="true" ignorePre="true"/>
                            <dbType type="TINYINT" ignoreLen="true" ignorePre="true"/>
                            <dbType type="TIME" ignoreLen="true" ignorePre="true"/>
                            <dbType type="TIMESTAMP" ignoreLen="true" ignorePre="true"/>
                            <dbType type="VARCHAR" default="true" defaultLength="200" ignorePre="true"/>
                            <dbType type="DATETIME" ignoreLen="true" ignorePre="true"/>
                            <dbType type="MEMO" ignoreLen="true" ignorePre="true"/>
                            <dbType type="YESNO" ignoreLen="true" ignorePre="true"/>
                            </dbTypes>
                            
                            <language name="java">
                            <talendToDbTypes>
                            <!-- Adviced mappings  -->
                            <talendType type="id_List"/>
                            <talendType type="id_Boolean">
                            <dbType type="YESNO" default="true"/>
                            <dbType type="BOOLEAN"/>
                            </talendType>
                            <talendType type="id_Byte">
                            <dbType type="TINYINT" default="true"/>
                            <dbType type="SMALLINT"/>
                            <dbType type="INTEGER"/>
                            </talendType>
                            <talendType type="id_byte[]"> </talendType>
                            <talendType type="id_Character">
                            <dbType type="VARCHAR" default="true"/>
                            </talendType>
                            <talendType type="id_Date">
                            <dbType type="DATE" default="true"/>
                            <dbType type="TIMESTAMP"/>
                            <dbType type="TIME"/>
                            <dbType type="DATETIME"/>
                            </talendType>
                            <talendType type="id_BigDecimal">
                            <dbType type="NUMERIC" default="true"/>
                            <dbType type="DOUBLE"/>
                            <dbType type="FLOAT"/>
                            <dbType type="DECIMAL"/>
                            <dbType type="REAL"/>
                            </talendType>
                            <talendType type="id_Double">
                            <dbType type="DOUBLE" default="true"/>
                            <dbType type="NUMERIC"/>
                            <dbType type="FLOAT"/>
                            <dbType type="DECIMAL"/>
                            <dbType type="REAL"/>
                            </talendType>
                            <talendType type="id_Float">
                            <dbType type="FLOAT" default="true"/>
                            <dbType type="DOUBLE"/>
                            <dbType type="NUMERIC"/>
                            <dbType type="DECIMAL"/>
                            <dbType type="REAL"/>
                            </talendType>
                            <talendType type="id_Integer">
                            <dbType type="INTEGER" default="true"/>
                            <dbType type="SMALLINT"/>
                            <dbType type="TINYINT"/>
                            <dbType type="COUNTER"/>
                            </talendType>
                            <talendType type="id_Long">
                            <dbType type="INTEGER" default="true"/>
                            <dbType type="SMALLINT"/>
                            <dbType type="TINYINT"/>
                            <dbType type="COUNTER"/>
                            </talendType>
                            <talendType type="id_Object"> </talendType>
                            <talendType type="id_Short">
                            <dbType type="SMALLINT" default="true"/>
                            <dbType type="INTEGER"/>
                            <dbType type="TINYINT"/>
                            <dbType type="COUNTER"/>
                            </talendType>
                            <talendType type="id_String">
                            <dbType type="VARCHAR" default="true"/>
                            <dbType type="MEMO"/>
                            </talendType>
                            </talendToDbTypes>
                            <dbToTalendTypes>
                            <dbType type="BIT">
                            <talendType type="id_Boolean" default="true"/>
                            </dbType>
                            <dbType type="BOOLEAN">
                            <talendType type="id_Boolean" default="true"/>
                            </dbType>
                            <dbType type="COUNTER">
                            <talendType type="id_Integer" default="true"/>
                            </dbType>
                            <dbType type="DATE">
                            <talendType type="id_Date" default="true"/>
                            </dbType>
                            <dbType type="DECIMAL">
                            <talendType type="id_Double"/>
                            <talendType type="id_BigDecimal" default="true"/>
                            <talendType type="id_Float"/>
                            </dbType>
                            <dbType type="DOUBLE">
                            <talendType type="id_Double" default="true"/>
                            <talendType type="id_BigDecimal"/>
                            <talendType type="id_Float"/>
                            </dbType>
                            <dbType type="FLOAT">
                            <talendType type="id_Float" default="true"/>
                            <talendType type="id_BigDecimal"/>
                            <talendType type="id_Double"/>
                            </dbType>
                            <dbType type="INTEGER">
                            <talendType type="id_Integer" default="true"/>
                            <talendType type="id_Short"/>
                            <talendType type="id_Long"/>
                            <talendType type="id_Byte"/>
                            </dbType>
                            <dbType type="NUMERIC">
                            <talendType type="id_Float"/>
                            <talendType type="id_BigDecimal" default="true"/>
                            <talendType type="id_Double"/>
                            </dbType>
                            <dbType type="REAL">
                            <talendType type="id_Float" default="true"/>
                            <talendType type="id_BigDecimal"/>
                            <talendType type="id_Double"/>
                            </dbType>
                            <dbType type="SMALLINT">
                            <talendType type="id_Short" default="true"/>
                            <talendType type="id_Integer"/>
                            <talendType type="id_Long"/>
                            <talendType type="id_Byte"/>
                            </dbType>
                            <dbType type="TINYINT">
                            <talendType type="id_Byte" default="true"/>
                            <talendType type="id_Integer"/>
                            <talendType type="id_Short"/>
                            <talendType type="id_Long"/>
                            </dbType>
                            <dbType type="TIME">
                            <talendType type="id_Date" default="true"/>
                            </dbType>
                            <dbType type="TIMESTAMP">
                            <talendType type="id_Date" default="true"/>
                            </dbType>
                            <dbType type="VARCHAR">
                            <talendType type="id_String" default="true"/>
                            </dbType>
                            <dbType type="DATETIME">
                            <talendType type="id_Date" default="true"/>
                            </dbType>
                            <dbType type="MEMO">
                            <talendType type="id_String" default="true"/>
                            </dbType>
                            <dbType type="YESNO">
                            <talendType type="id_Boolean" default="true"/>
                            </dbType>
                            </dbToTalendTypes>
                            </language>
                            </dbms>
                            </mapping>