Rules
What is a Rule
A rule is a set of operations that outputs anonymized or synthesized data into new datasets, the same or different datasources (sinks).
A rule is comparable to a program or an algorithm.
Rules run in jobs.
How to create a new rule
Open the Rules area of the tap model and click Create. The New rule window has two parts:
- General: the Name of the rule (required, "Rule name is required") and a Description of its purpose.
- Default Options: the options the rule uses when it runs, described below.
Import Rule creates a rule from a file exported with Export rule.
Options
The Default Options of a rule are:
| Option | Values | Default | What it does |
|---|---|---|---|
| Concurrency | 1 or more | 1 | Number of entities streamed at the same time |
| Continue Streaming On Fail | checkbox | on | If an entity fails, the job goes on with the other entities. When off, the job stops at the first entity that fails |
| Retry On Fail | checkbox | off | Retries a failed write batch by splitting it in half, again and again, until the record that fails is isolated. Used by Postgres, MySQL, Oracle, MSSQL, Databricks and Salesforce sinks |
| Load Options | Truncate, Drop, Append, Update, Merge | Truncate | What to do when the sink already has data (see below) |
| Determinism | Random, Deterministic | Random | Random gives different results in every run. Deterministic gives the same results in every run of the rule |
| Seed | 1 to 9999999 | 0 | Number that initializes the random generator. Required with Deterministic and disabled with Random. Generate picks a random seed |
| Check foreign keys | Auto, Do not check, Force check | Auto | Stored with the rule (see the note below) |
| Read batch records | number of records | 32768 | Records read from the source in every cycle |
| Write batch records | number of records | 32768 | Records written to the destination in every cycle |
| Stream content | Data and metadata, Data only, Metadata only | Data and metadata | What the job writes. Metadata only writes no records: a sink gets its tables (created, emptied or dropped as the Load Options say) and a dataset gets the description of its entities. Data only writes the records, and a dataset gets no description of its entities |
| Dictionary | see below | No dictionary | Reuses the values already masked in previous runs |
Load Options:
| Value | Effect on the sink |
|---|---|
| Truncate | Removes the data of the tables but keeps their DDL |
| Drop | Deletes both the data and the DDL |
| Append | Adds the output of the rule to the existing data |
| Update | Updates the rows that have the same primary key. New rows are not inserted |
| Merge | Updates the rows that have the same primary key and inserts the new ones |
Update and Merge need a primary key in the entity; without one the entity fails with an error like "Cannot update/merge database without any defined primary keys".
Dictionary modes:
| Mode | Values are reused |
|---|---|
| No dictionary | Never |
| Reuse values on the same entity+field | Only in the same field of the same entity |
| Reuse values with the same label or same entity+field | In fields with the same label, or the same field of the same entity |
| Reuse values in every field | In any field |
With a dictionary you can also check:
- Cache dictionary (on by default): keeps a local cache of the dictionary for the project.
- Store new transformations in the dictionary (on by default): saves the new values so later runs reuse them.
- Overwrite existing dictionary (off by default): replaces the values already stored.
These checkboxes are disabled with No dictionary. For more information check the article on how to use dictionaries.
Check foreign keys is saved with the rule and with its jobs, but in this version the job does not use it. To keep child rows consistent with their parent rows, use Ensure Referential Integrity in Where, Limit, Read Query or Synthesize.
Ignore already anonymized values
Ignore already anonymized values protects data that was already anonymized when a rule runs again over the same tap. It is not a rule option: you choose it in each job that overwrites the tap, and only when a dictionary is used (the checkbox is disabled with No dictionary). It appears in:
| Where | Shown when | Section |
|---|---|---|
| New job | Overwrite current tap is selected | Transform options |
| New pipeline | Overwrite tap is selected | Transform options |
It is off by default and it is never taken from the rule. In any job that doesn't overwrite the tap it is always off, whatever value was saved.
When it is on, every value is first looked up in the dictionary:
value read from the tap
│
├── stored as an original value ───► replaced with its stored
│ anonymized value
│
├── stored as an anonymized value ──► kept as it is
│ (already anonymized)
│
└── not in the dictionary ──────────► anonymized as usualIf all the non-empty fields of a row that use the dictionary are already anonymized, the row is skipped and not written, so it stays as it is in the tap. The job log shows a line per entity like customers: 120 values ignored, 40 rows skipped (already anonymized).
Before 2.0.0 this option was on by default in every rule with a dictionary. When you upgrade to 2.0.0, a migration turns it off in all rules, rule versions, pipelines and scheduled jobs that have not started yet. Jobs that already ran keep their options, so a restart behaves as before. If you need it, turn it on again in the job that overwrites the tap.
Actions
The rules list shows a Run button for each rule and an Actions menu with:
- Export rule: downloads the rule as a
.jsonfile, which you can bring into another model with Import Rule. - Edit rule: edits the rule options described in the above section Options.
- View operations: goes to the operations page of the rule.
- View jobs: shows the jobs of the rule.
- Delete: deletes the rule from the model, after asking "Are you sure you want to delete this rule?".
Run opens the New job panel with the rule already selected, From set to the tap and To set to New Dataset. You can change the destination to a sink, an existing dataset or Overwrite current tap.
The panel starts with the options of the rule, and you can change them for this run only:
- Concurrency, Continue Streaming On Fail, Retry On Fail, Read batch size and Write batch size.
- Target entities (the load mode, when the output goes to a sink) starts at the load mode of the rule. If the sink doesn't support it, the first mode it supports is used instead. Overwrite current tap always uses Update, and the job asks for confirmation ("Warning: DATA LOSS WILL OCCUR"). It is disabled when the tap doesn't allow overwrites.
- Transform options: Determinism, Seed, Check foreign keys and Dictionary, plus Ignore already anonymized values when overwriting the tap.
Check your Pipelines before deleting a rule because the pipeline may become inconsistent if the rule is being used.
Operations list
After creating the rule, click on the name to enter into operations page. Add operation opens a grid with the operations you can add, divided into three areas. Each operation can be added once per rule; the operations already in the rule are shown as selected.
Query
Query Operations change how the data is read from the tap, as if it were a SQL query:
| Operation | Description in the grid | In SQL |
|---|---|---|
| Include/Exclude | Filter which entities are streamed | FROM |
| Select | Set which fields to stream | SELECT field, ... |
| Where | Filter records by value | WHERE |
| Read Query | Use a custom SQL/no-sql query to extract data from the tap | Your own query |
| Order | Order in which records are streamed | ORDER BY |
| Limit | Reduce the number of records streamed | LIMIT |
| Rate | Throttle the stream speed |
Transform
Transform Operations change the data or the order in which it is processed:
| Operation | Description in the grid |
|---|---|
| Sequence | Order in which entities are streamed |
| Synthesize | Populate entities with fake data |
| Anonymize | Mask and obfuscate entities |
| Transform | Transform records value through code |
| Schema Update | Modify the database schema |
These transformations output anonymized or synthesized data into new datasets, the same or different datasources (sinks).
Output
Output Operations change the data written to the destination:
| Operation | Description in the grid |
|---|---|
| Max | Reduce the number of records written |