This scenario is a two-component Job created in Talend Studio. In this Job, tMySQLInvalidRows reads the email addresses for people from a specific country from a MySQL database table, filters data using a WHERE clause to narrow down the validation process, checks the email values against the given Talend Studio email pattern and finally extracts filtered data including the invalid rows and displays them on the console.
Below is the database table used in this example, some customers are from the USA and others are from Canada. The Email column contains some invalid addresses. The tMySQLInvalidRows component filters data in the Email column to read only the emails for the customers from the USA, and then validates these email addresses against the EmailAddress pattern.
In this scenario, we have already stored the schemas of the input table in the Repository. For more information about storing schema metadata in the Repository tree view, see Talend Studio User Guide.
Setting up your Job
In the Repository tree view, expand in succession the Metadata and the DB Connections nodes where you have stored the input schemas and drop the relevant connection onto the design workspace.
The [Components] dialog box displays.
Select tMySQLInvalidRows from the list and click OK to close the dialog box.
The tMySQLInvalidRows component displays on the workspace. The MySQL table used in this scenario is called customers. It holds the customers' customer_id, account_num, Iname, fname, country and Email columns.
Drop tLogRow from the Palette onto the design workspace.
Connect the two components together using the Main link.
Setting up the schema
Double-click tMySQLInvalidRows to display its Basic settings view and define its properties.
All database connection fields are automatically filled in. If you do not define your input files in the Repository, fill in the details manually after selecting Built-in in the Property Type field
From the Validation type list, select Regex pattern validation.
This will validate data in the selected rows against a regex pattern. For an example scenario about validating data against DQ rule, see Scenario 2: Checking customer table against a given DQ rule to select customer records.
In the Table Name field, type in the name of the database table on which you want to run the Job, customer1 in this example.
In the Where clause field, type in the WHERE clause that will restrict the number of the analyzed rows.
In this example you want to examine only the emails of the customers from the USA.
In the Analyzed column list, select the column you want to analyze, Email in this example.
In the Patterns list, select the Talend Studio database pattern against which you want to check addresses from the Email column, Email Address in this example.
If you select the Custom pattern check box, you can customize the regular expression against which the data is to be checked.
Double click tLogRow to open its Basic settings view and define its properties as needed.