tMySQLInvalidRows
Checks MySQL database rows against specific Data Quality patterns (regular
expression) or Data Quality rules (business rule).
tMySQLInvalidRows extracts DB rows that do not match a given data quality
pattern or rule. You can then implement any required correction.
tMySQLInvalidRows Standard properties
These properties are used to configure tMySQLInvalidRows running in the Standard Job framework.
The Standard
tMySQLInvalidRows component belongs to the Data Quality and the Databases families.
This component is available in Talend Data Management Platform, Talend Big Data Platform, Talend Real Time Big Data Platform, Talend Data Services Platform, Talend MDM Platform and Talend Data Fabric.
connector. The properties related to database settings vary depending on your database
type selection. For more information about dynamic database connectors, see Dynamic database components.
Basic settings
Database |
Select a type of database from the list and click |
Validation type |
Either Regex pattern validation |
 |
Regex pattern validation: |
 |
DQ rule validation: Validate data |
Property type |
Either Built-in or Repository. |
 |
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 relevant connection component to Note: When a Job contains the parent Job and the child Job, if you
need to share an existing connection between the two levels, for example, to share the connection created by the parent Job with the child Job, you have to:
For an example about how to share a database connection |
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 |
 |
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 |
Advanced settings
Additional JDBC Parameters |
Specify additional connection properties for the DB connection you Note:
You 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 |
Global Variables
Global Variables |
NB_LINE: the number of rows read by an input component or
QUERY: the query statement being processed. This is a Flow
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 |
Usage
Usage rule |
This component can be used as a start or intermediary step. It |
Note:
Available only for Regex pattern |
Analyzed column |
Note:
Available only for Regex pattern |
Custom pattern |
Note:
Available only for Regex pattern |
Patterns list |
Note:
Available only for DQ rule |
DQ rule list |
Note:
Available only for DQ rule |
Query type |
 |  |
 |  |
Note:
Available only for DQ rule |
Guess Query |
Note:
Available only for DQ rule |
Guess schema |
Note:
Available only for DQ rule |
Query |
Dynamic settings |
Click the [+] button to add a row in the table The Dynamic settings table is For examples on using dynamic parameters, see Reading data from databases through context-based dynamic connections and Reading data from different MySQL databases using dynamically loaded connection parameters. For more information on Dynamic |
Reading email addresses from a DB table and retrieving specific
data
This scenario applies only to Talend Data Management Platform, Talend Big Data Platform, Talend Real Time Big Data Platform, Talend Data Services Platform, Talend MDM Platform and Talend Data Fabric.
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 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.
Checking customer table against a given DQ rule to select customer
records
This scenario applies only to Talend Data Management Platform, Talend Big Data Platform, Talend Real Time Big Data Platform, Talend Data Services Platform, Talend MDM Platform and Talend Data Fabric.
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:
Dropping and linking the components
-
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.
Configuring the connection to the database
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.
Configuring the query of the customer records 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
.Email
like '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 reading
18<=((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:12345"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.
Executing the Job
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.
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.