On January 27, 2021, Google is changing the required permissions for attaching IAM roles to service accounts. If you are using IAM roles for your Google service accounts, please see Changes to User Management.
Contents:
- A data quality rule evaluates the values in one or more columns against a test criteria that you define.
- Cloud Dataprep by TRIFACTA® INC. includes a library of pre-defined data quality rule types. For more information, see Data Quality Rules Reference.
- You can also create a custom rule using functions in the language.
- Data quality rules are one of several features available for monitoring data quality during import, transformation, and export of your datasets. For more information, see Overview of Data Quality.
NOTE: Data quality rules are not transformation steps. They assess the current state of the sampled data in the Transformer page.
NOTE: As you apply transformation steps to the data, the state of your data quality rules is automatically updated to reflect the changes. If you delete columns or other elements referenced in the data quality rules, errors are generated in the Transformer page.
Add Rule
You can add a rule from inside the Transformer page.
Steps:
- You create rules inside the Transformer page. In the toolbar at the top of the screen, click the Data Quality Rules icon on the right side of the toolbar.
- The Data Quality rules panel opens in the context panel. For more information, see Data Quality Rules Panel.
If you have not created any rules, the panel is empty. To create a new rule, click Add rule.
Tip: You can review a set of suggested data quality rules that are based on your dataset and add them as needed. Click View suggestions. For more information, see Data Quality Rules Panel.
- The available types of data quality rules are displayed. Select your rule type.
- A simple one is
Not Null
. See Examples below. - You can also add custom rules based on formulas that you specify. See "Add Custom Rule" below.
- A simple one is
May be missing: Some rule types support the May be missing checkbox. When it is enabled, the Data Quality rule allows missing values to be acceptable for a specified column.
NOTE: The May be missing rule parameter is not applicable to Not Null, Not Missing, Not Equal, Not In Set, and Formula rule types.
Select the column or columns to which the rule applies.
Tip: Some rules can be applied to multiple columns.
Click Add.
- Specify the other parameters as needed.
Review the previewed results.
Tip: To simplify the preview, click the Show Only Affected Columns checkbox in the status bar.
- When finished, click Add to add the rule.
The new rule is displayed in the Data Quality Rules panel. In the data quality bar for the rule, green indicates the row values that have passed the rule, and red indicates the row values that failed.
- Hover over either color to see the row counts and percentage.
- Select either color to highlight the indicated rows in the data grid.
Tip: After creating a rule, you can jump back and forth between the Recipe panel and this panel to review how your changes to your recipe steps affect the data quality bars for your rules.
Additional options are available in the context menu for the rule. For more information, see Data Quality Rules Panel.
Examples
Example - storeAddress column is Not Missing
The following data quality rule tests the values in the storeAddress
column to see if they are missing (empty) values.
Data Quality Rule | Not Missing |
---|---|
Parameter: Column | storeAddress |
Example - primaryKey column is Unique
The following rule evaluates the primaryKey
column to determine if all values in it are unique.
Data Quality Rule | Unique |
---|---|
Parameter: Column | primaryKey |
Example - SKU column matches pattern of SKU + 6 digits
Suppose the values of your SKUs must be in the form of "SKU
+ 6 digits".
Following uses Patterns to perform the match. For more information on Patterns , see Text Matching.
Data Quality Rule | Match |
---|---|
Parameter: Column | SKU |
Parameter: Matches pattern | `SKU{digit}{6}` |
Parameter: Ignore case | false |
Example - orderColor must be "Blue", "Yellow" or "Green"
This rule tests the values in the orderColor
column to verify that all values are Blue
, Yellow
, or Green
.
In the following, the Acceptable values must be formatted as an array. See below.
Data Quality Rule | In Set |
---|---|
Parameter: Column | orderColor |
Parameter: Acceptable values | ['Blue','Yellow','Green'] |
Add Custom Rule
You can add custom rules using formulas containing Wrangle functions.
Wrangle is the proprietary language used to transform your data. You can also apply the functions of the language to your data quality rules. For more information, see Wrangle Language.
Steps:
- In the Data Quality Rules panel, click Add Rule.
- Under Other Rules, select
Formula
. In the Formula textbox, enter the Wrangle formula to test your data.
NOTE: The formula that you provide must evaluate to
true
orfalse
.true
values are highlighted in green in the data quality bar for the rule.For aggregation functions, you can group the evaluation of your rule based on the values in your grouping column.
Tip: You can group by multiple columns. The first column is the outermost grouping.
To add the rule, click Add.
Examples
Example - sum of daily sales >= 100
You can use data quality rules to perform some data analysis functions. For example, suppose you want to flag the dates where the total sales of all of your orders was less than 100.
Data Quality Rule | Formula |
---|---|
Parameter: Formula | SUM(mySales) >= 100 |
Parameter: Group | myDate |
When this rule is added, the rows whose date total is less than 100 are flagged in red.
Edit Rule
To edit a rule, select Edit rule from the context menu for the rule in the panel.
Delete Rule
To delete a rule, select Delete rule from the context menu for the rule in the panel.
Export Rules
Job results
When you generate a profile as part of your job results, you can download the profile in JSON or PDF format.
When you download the profile in JSON format, the set of rules for the job are also included. Search for profilerRules
in the JSON file.
For more information, see Job Details Page.
Flows
When flows are exported and imported, the rule definitions for the recipes in the flow are also exported. For more information, see Export Flow.
This page has no comments.