Warning
This component will be available in the Palette of
Talend Studio on the condition that you have subscribed to one of
the Talend Platform products.
|
Component family |
Data Quality |
|
|
Function |
tMySQLInvalidRows checks database |
|
|
Purpose |
tMySQLInvalidRows allows you to |
|
|
Basic settings |
Validation type |
Either Regex pattern validation |
|
Regex pattern validation: |
||
|
DQ rule validation: Validate data |
||
|
|
Property type |
Either Built-in or Repository. Since version 5.6, both the Built-In mode and the Repository mode are |
|
Built-in: No property data stored |
||
|
|
|
Repository: Select the repository |
|
DB Version |
Select the MySQL version you are using. | |
|
|
Use an existing connection |
Select this check box and in the Component List click the NoteWhen a Job contains the parent Job and the child Job, if you need to share an existing
For an example about how to share a database connection across Job levels, see |
|
|
Host |
Database server IP address. |
|
|
Port |
Listening port number of DB server. |
|
|
Database |
Name of the database. |
|
|
Username and |
DB user authentication data. To enter the password, click the […] button next to the |
|
|
Schema and Edit |
A schema is a row description, it defines the number of fields to Since version 5.6, both the Built-In mode and the Repository mode are |
|
|
|
Built-in: You create and store |
|
|
|
Repository: You have already |
|
|
Table Name |
Enter the name of the table to be read. |
|
|
Where clause |
Enter a WHERE clause to define a row filter on the table. You can use the WHERE clause to filter the rows you want to |
Note Available only for Regex pattern |
Analyzed column |
Select from the schema list the column to analyze. |
Note Available only for Regex pattern |
Custom pattern |
Select this check box to define manually your own customized |
Note Available only for Regex pattern |
Patterns list |
Select from the pattern list the pattern against which you want to |
Note Available only for DQ rule |
DQ rule list |
Select from the list the rule against which you want to check the |
Note Available only for DQ rule |
Query type |
Either Built-in or Repository: |
|
Built-in: Fill in manually the |
||
|
Repository: Select the relevant |
||
Note Available only for DQ rule |
Guess Query |
Click the Guess Query button to |
Note Available only for DQ rule |
Guess schema |
Click the Guess Schema button to |
Note Available only for DQ rule |
Query |
Enter your DB query paying particular attention to properly |
|
Advanced settings |
Additional JDBC Parameters |
Specify additional connection properties for the DB connection you NoteYou can press Ctrl+Space to |
|
Enable stream |
Select this check box to enables streaming over buffering. This allows reading from large tables without consuming large amount of memory in order to optimize the performance. |
|
|
Trim all the String/Char columns |
Select this check box to remove leading and trailing whitespace from all the String/Char columns. |
|
|
Trim column |
Select this check box to remove leading and trailing whitespace This check box is not visible if Trim all |
|
|
tStatCatcher Statistics |
Select this check box to collect log data at the component |
|
|
Dynamic settings |
Click the [+] button to add a row in the table and fill The Dynamic settings table is available only when the For more information on Dynamic settings and context |
|
|
Global Variables |
NB_LINE: the number of rows read by an input component or
QUERY: the SQL query statement being processed. This is a ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
|
Usage |
This component can be used as a start or intermediary step. It |
|
|
Limitation |
n/a |
|
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.
Executing the Job
-
Save your Job.
-
Press F6 to execute it.

The tMySQLInvalidRows component analyzed the
email addresses only for customers from the USA in the database table against
the selected SQL pattern (Email Address), and then it
extracted all filtered data including the invalid email addresses.
This scenario is a three-component Job that checks a MySQL customer table against a
given data quality rule so as to query specific customer records.

These components used in the Job are:
-
tMysqlConnection: this component creates the
connection to the MySQL database of interest so that the other components can
reuse it. -
tMySQLInvalidRows: this component reuses the
connection created by tMysqlConnection and
query the customer records of interest against the given data quality
rule. -
tLogRow: this component presents the result
of running this Job.
To replicate this scenario, proceed as illustrated in the following sections:
-
From the Palette, drop tMysqlConnection, tMySQLInvalidRows and tLogRow onto the design workspace.
You can label any component in the workspace the way you need. For further
information about how to label a component, see Talend Studio User Guide. -
Right-click tMysqlConnection and select
the Trigger > OnSubjobOk link to connect this component to tMySQLInvalidRows. -
Repeat this operation but select the Row
> Main link to connect tMySQLInvalidRows to tLogRow.
To configure the connection to the MySQL database of interest, proceed as
follows:
-
Double-click tMysqlConnection to open its
Component view.
-
In the DB version field, select the
version of your MySQL database. It is Mysql
5 in this example. -
In the Host field, type in the server IP
address of the database to which you want to connect, localhost in this example. -
In the Port field, type in the port
number of the database to which you want to connect, 3306 in this example. -
In the Database field, enter the name of
the database in which you need to check the customer table, crm in this example. -
In the Username and the Password fields, enter the authentication
information to connect to the database of interest.
-
Double-click tMySQLInvalidRows to open
its Component view.
-
In the Validation type field, select
DQ rule validation in order to use the
given data quality rule. -
Select Use an existing connection to
reuse the connection that tMysqlConnection
creates. -
Click the […] button next to Edit schema to open the schema editor.

-
Click the [+] button three times to add
throw rows and rename them as Name,
DOB and Email, respectively. -
In the DOB row, select VARCHAR in the DB
type column, enter 19 in
the Length column and 0 in the Precision column. -
Click OK to validate these changes and
accept the propagation prompted by the pop-up dialog box. -
In the Table name field, enter or browse
to the database table to be checked, cust
in this example. -
In the Where clause field, type in the
where clause to be used, in addition to the given data quality rule, to
query the customer data of interest. In this scenario, enter
within the quotation marks tocust.Emaillike 's%'
retrieve the email records beginning with the letter s or S. -
In the DQ rule list field, select the
data quality rule to be used. In this scenario, select cust_age. This rule is a demo rule reading118<=((TO_DAYS(NOW())-TO_DAYS(DOB))/365)You can check the available data quality rules in Libraries > Rules > SQL of the DQ
Repository. The cust_age
rule can be imported from the TDQEEDEMOJAVA project.
For further information about the DQ
Repository and its items and about how to import the data
quality demo project, see the Talend Studio
User Guide -
Click Guess Query to generate the
corresponding query clause that uses the Not clause. -
In the Query field, change 18 to 20 to
modify the clause as the following:123"SELECT `Name`, `DOB`, `Email` FROM `crm`.`cust`WHERE (NOT ( 20>((TO_DAYS(NOW())-TO_DAYS(DOB))/365) )AND `cust`.`Email` like 's%')"This clause allows you to select the customers whose ages count 20 or more.
The tLogRow component presents the execution
result of the Job. You can configure the presentation mode on its Component view.
To do this, double-click tLogRow to open the
Component view and in the Mode area, select the Table (print values in
cells of a table) option.
-
To execute this Job, press F6.
Once done, the Run view is opened automatically,
where you can check the execution result.

You can read that the customer records beginning with the letter S are retrieved
and their ages are all more than 20.