You can create a semantic type based on a regular expression in Talend Dictionary Service and add it to the list of recognized data types in Talend Data Stewardship.
In Talend Dictionary Service, not every type of data can currently be matched with and validated against one of the predefined semantic types. Italian social security numbers, also known as codice fiscale, are currently not recognized for example.
Let's say that you work for an Italian company, only dealing with Italian customers. In this example, you need to intervene and manage some customer data, such as their names, email address, or their social security number.
When defining the data model in Talend Data Stewardship, you will be obliged to
set the semantic type for the column containing the social security number to
text as there is no predefined semantic type for Italian social
security number. This is a bit disappointing and you would like to create a more
specific category in order to match this type of data: a
codice_fiscale semantic type in this case.
You will create this new semantic type in Talend Dictionary Service, and it will be automatically available in Talend Data Stewardship so that your data can be matched with and validated against a proper type.
In the homepage, click
- Enter a name and a description for the new semantic type.
- Select the semantic type from the Type list.
Keep the Use for validation switch activated.
Using a regular expression, a dictionary or a compound type for validation means that it will be used to define which values are considered right or wrong in a given column. The result of this validation process can be seen in the quality bar of each column in your datasets.
In any case, regular expressions or dictionary of values are used for data discovery, that calculates the matching percentage between the reference values and your data to define the semantic type of each column.
In this example, if you were to deactivate the switch, the regular expression would only be used for data discovery, and no value would be considered invalid.
From the Content list, select the type of content you
want to validate.
This option helps to optimize performance. Only the data which matches the selected type is validated
Option Description Any character The complete string is validated against the regular expression Alphabetic Strings that contain alphabetical characters and no numeric character are validated against the regular expression Numeric Strings that contain numeric characters and no alphabetic character are validated against the regular expression
Enter the regular expression syntax in the Validation
This regular expression is designed to match the Italian codice fiscale, which is an alphanumeric code of 16 characters.
Click SAVE AND PUBLISH to send the semantic type to
the Talend Dictionary Service
server and make it available to be used by the system.
Clicking SAVE AS DRAFT stores the new type on the server without propagating it to the system. The new type is not usable unless it is published. For a use case of this option, let's say that you have new semantic types to deploy as part of a new project. You can prepare the work by creating the semantic types and save them as draft before the go-live of the project, and can deploy the semantic types only the day of go-live.
Go back to Talend Data Stewardship and create the data model for the Italian customers data.
The new semantic category
codice_fiscaleis available now in the list of semantic types and you can set it for the column containing the social security number.
codice_fiscalesemantic type, that you created in Talend Dictionary Service.