Using a basic validation rule - 6.2

Talend MDM Platform Studio User Guide

English (United States)
Talend MDM Platform
Talend Studio
Data Governance
Data Quality and Preparation
Design and Development

After setting up a validation rule, you can apply it on your Job designs. For example, let's apply a basic check for correct values validation rule when reading a database table. This scenario is based on the basic check validation rule created in Designing a Job. For more information about this rule, see Basic rule.

Setting up the Job environment

  1. From the Palette, drop these components onto the design workspace: a database input component, here tMysqlInput, that you will read and check the values of, two tFileOutputDelimited components to extract the valid data in one file and the rejected ones in another file, and a tJava component to display the number of lines processed in the console.

  2. Connect the input database component to the first tFileOutputDelimited component using a Row > Main link, and connect the tMysqlInput component to the tJava component with a Trigger > OnSubjobOk link.


    You will be able to create the reject link between the tMysqlInput and the second tFileOutputDelimited component only when you will have applied the validation rule to the tMysqlInput component.

Configuring the input component

  1. Double-click the tMysqlInput component to display its Basic settings.

  2. Select Repository as Property type and click the three-dot button next to the field to retrieve the connection properties that corresponds to the metadata you want to check.

  3. Select Repository from the Schema drop down list and click the three-dot button next to the field to retrieve the schema that corresponds to your database table.

  4. Click the three-dot button next to the Table field to select the table to check.

  5. Click Guess Query to automatically retrieve the query corresponding to the table schema.

Applying the validation rule and creating a reject link

As the On select option was selected for this validation rule, the validation rule must be applied to the input component.

  1. Click the Validation Rules tab of the tMysqlInput Component view.

  2. Select the Use an existing validation rule check box to apply the validation rule to the component.

  3. In the Validation Rule Type list, select Repository and click the [...] button to select the validation rule from the [Repository Content] window.

  4. Right-click tMysqlInput, select Row> Reject in the menu and drag to the second tFileOutputDelimited component to create a reject link between the two components.

    If you have enabled the Reject link option for this validation rule you can retrieve the rejected data to a reject flow.

Configuring the output components and viewing the Job execution result

  1. Double-click the first tFileOutputDelimited component to display its Basic settings.

  2. In the File Name field, specify the path and name of the file to write with the valid data.

  3. Define the row and field separators in the corresponding fields.

  4. Select the Include Header check box to include column headers in the output data.

  5. Repeat the steps above on the second tFileOutputDelimited component to configure the output of the rejected data.

  6. Double-click the tJava component to display its Basic settings.

  7. In the Code field, type in the code that will display the number of updated, inserted and rejected lines processed:

    System.out.println("Valid data: "+((Integer)globalMap.get("tFileOutputDelimited_1_NB_LINE"))+"\nRejected
    data: "+((Integer)globalMap.get("tFileOutputDelimited_2_NB_LINE")));

  8. Save your Job and press F6 to execute it.

Valid data is outputted in the first delimited file and rejects to the second, and the console displays the number of valid lines and the number of rejects processed in the Job.