Scenario: Loading data into a Teradata database - 6.3

Talend Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a Job that creates a new Teradata database table, writes data into a delimited file, then loads the data from the file into this table, and finally retrieves the data from the table and displays it on the console.

Dropping and linking the components

  1. Create a new Job and add the following components by typing their names in the design workspace or dropping them from the Palette: a tTeradataRow component, a tFixedFlowInput component, a tFileOutputDelimited component, a tTeradataTPTExec component, a tTeradataInput component, and a tLogRow component.

  2. Connect tFixedFlowInput to tFileOutputDelimited using a Row > Main connection.

  3. Do the same to connect tTeradataInput to tLogRow.

  4. Connect tTeradataRow to tFixedFlowInput using a Trigger > On Subjob Ok connection.

  5. Do the same to connect tFixedFlowInput to tTeradataTPTExec and tTeradataTPTExec to tTeradataInput.

Configuring the components

Creating a new Teradata database table

  1. Double-click tTeradataRow to open its Basic settings view.

  2. Fill in the Host, Database, Username, and Password fields with your Teradata database connection details.

  3. In the Query field, enter the following SQL statement to create a new table named person with three columns id, name, sex.

    CREATE SET TABLE samples.person,
    FALLBACK,
    NO BEFORE JOURNAL,
    NO AFTER JOURNAL
    (
      id INTEGER NOT NULL,
      name VARCHAR(50),
      sex VARCHAR(20)
    )
    UNIQUE PRIMARY INDEX (id)

Preparing the source data

  1. Double-click tFixedFlowInput to open its Basic settings view.

  2. Click the [...] button next to Edit schema to open the schema editor.

  3. Click the [+] button to add three columns: id of the integer type, name and sex of the string type.

  4. Click OK to close the schema editor and accept the propagation prompted by the pop-up dialog box.

  5. In the Mode area, select Use Inline Content (delimited file) and enter the input data in the Content field.

    1;Ford;Male
    2;Rose;Female
    3;Sabrina;Female
    4;Teddy;Male
    5;Kate;Male
  6. Double-click tFileOutputDelimited to open its Basic settings view.

  7. In the File Name field, specify the file into which the input data will be written. In this example, it is E:/person.csv.

Loading the source data into an empty table

  1. Double-click tTeradataTPTExec to open its Basic settings view.

  2. Fill in the TDPID, Database name, Username, and Password fields with your Teradata database connection details.

  3. In the Table field, enter the name of the table into which the source data will be loaded. In this example, it is person.

  4. In the Script generated folder field, browse to the directory under which the Teradata Parallel Transporter script file will be created during the Job execution. In this example, it is E:/.

  5. In the Load file field, browse to the file that contains the source data. In this example, it is E:/person.csv.

  6. In the Error file field, specify the file in which log messages will be recorded. In this example, it is E:/error.log.

  7. Click the [...] button next to Edit schema to open the schema editor.

    Click the [+] button to add three columns: id of the integer type, name and sex of the string type. Note that id and name in Db Column are enclosed in a pair of \" since they are Teradata database keywords.

    Click OK to validate these changes and close the schema editor.

  8. Click Advanced settings to open its view, and then select the Apply TPT consumer operator optional attributes check box and click the [+] button below the Optional attributes table to add the following attributes needed: ErrorLimit, ErrorTable1, QueryBandSessInfo, and TraceLevel.

    Note

    For VARCHAR attributes, enter their values between double quotation marks.

Retrieving data from the Teradata database table

  1. Double-click tTeradataInput to open its Basic settings view.

  2. In the Table Name field, enter the name of the table to read data from. In this example, it is person.

  3. In the Query field, enter the following SQL statement to retrieve data from the table person.

    SELECT * FROM samples.person ORDER BY id
  4. Click the [...] button next to Edit schema to open the schema editor.