Transformers
A transformer writes the values of one or more columns. Set it with type: in a table’s transformations. This page groups the transformers by what they do. Each name links to its entry in All Transformers, which lists its parameters and examples.
tables:
- table_name_with_schema: "public.customer"
transformations:
- columns: ["email"]
params:
type: person_generator
column_templates: ["${email}"]
Reading the tables
-
Modes: every transformer works in MASKING mode. Most also work in GENERATION. The exceptions, which only change existing values, are the transformers in Masking existing values and JSON, XML and multi-value columns, and
passthrough. -
Columns: the column types a transformer accepts. Any means any type. See Data Types.
-
Several columns: transformers that can write several columns at once, keeping their values consistent with each other, say so in their description.
If you don’t set a transformer
You don’t need to set a transformer for every column. Columns you don’t list get one from the rules in default_config:
-
In KEEP mode, columns are copied with
passthrough. -
In MASKING mode, every column gets a masking transformer. Primary and foreign keys get a hashing transformer, such as
unique_hashingfor numeric keys, so keys change but joins still work. If no rule matches a column,safety_mode: STRICT(the default) stops the run. -
In GENERATION mode, the engine learns each column from the input and picks a generator.
Run tdk default-config to see the rules. See How Masking Works and How Generation Works.
People, addresses and financial data
| Transformer | What it does | Columns |
|---|---|---|
Names, titles, emails, usernames, company names, phone numbers and social security numbers. Takes several columns and keeps a row’s values consistent. Supports many locales. |
Text |
|
Street names, house and flat numbers, cities, regions, postcodes, countries, coordinates and time zones. Takes several columns and keeps a row’s values consistent. |
Text |
|
Card numbers by card type, IBAN and BIC codes, US routing numbers, stock tickers and stock markets. Takes several columns. |
Text |
Masking existing values
These transformers work in MASKING mode only.
| Transformer | What it does | Columns |
|---|---|---|
Replaces characters with others from the same group, such as digits with digits, so the value keeps its length and format. Can be limited to the first or last characters, a substring, a regex or a set of characters. Not reversible. |
Text |
|
Masks the first or last characters of a value with a mask character, or keeps them and masks the rest: for example, keep the last 4 digits of a card number. |
Text |
|
Adds random noise to numbers, so values stay close to the originals. |
Numeric |
|
Hashes values to unique outputs. The same input always gives the same output, so keys stay joinable. MASKING uses it for numeric keys. |
Numeric |
|
Hashes date and time values to unique outputs, consistently. MASKING uses it for date keys. |
Date |
|
Hashes enum values to unique outputs, consistently. |
Text |
|
Remaps Temenos T24 record IDs, and references to them, to new IDs. The same input always gives the same output. |
Text |
Sampling from distributions
| Transformer | What it does | Columns |
|---|---|---|
Picks values from categories with weights. You provide the categories, read them from a CSV file, or let the engine learn them from the input. Learned categories are real input values. Can take several columns. |
Any |
|
Samples numbers from a distribution. You give its parameters, or the engine fits them to the input. |
Numeric |
|
Samples numbers from bins, each chosen with a given probability. |
Numeric |
|
Samples dates from a distribution. You give its parameters, or the engine fits them to the input. |
Date |
|
Samples values from a distribution and keeps only those that meet a condition. Can take several columns. |
Numeric, date |
Keys, sequences and identifiers
| Transformer | What it does | Columns |
|---|---|---|
Unique integers in sequence, for ID columns. |
Numeric |
|
Unique strings in sequence, from upper-case letters and digits. |
Text |
|
UUIDs. |
Any |
|
Strings that match a regular expression. Without a pattern, random characters about as long as the original. |
Any |
|
Fills foreign keys with the primary key values of parent rows. The platform sets it up wherever related tables are generated: don’t set it yourself. |
Any |
|
For primary keys that are also part of a foreign key. The platform sets it up: don’t set it yourself. |
Any |
Copying, constants and empty values
| Transformer | What it does | Columns |
|---|---|---|
Copies the input value unchanged. MASKING mode only. Can take several columns. |
Any |
|
Fills the column with nulls. Can take several columns. |
Any |
|
One value for the whole column: the one you give, or a default for the column’s type. |
Any |
|
One number for the whole column. |
Numeric |
|
One string for the whole column. |
Text |
|
One date for the whole column. |
Date |
|
One boolean for the whole column. |
Boolean |
|
One XML value for the whole column. |
Any |
|
Skips the processing of a whole table. In XML generation, it removes the selected attribute or text node. |
Any |
JSON, XML and multi-value columns
These transformers work in MASKING mode only.
| Transformer | What it does | Columns |
|---|---|---|
Transforms the JSON values that JSON pointers select, and keeps the rest of the document. |
Any |
|
Transforms the XML nodes that XPath expressions select, and keeps the rest of the document. |
Any |
|
Masks each value in a Temenos T24 multi-value column stored as JSON, with an inner transformer. |
Any |
Logic and custom code
| Transformer | What it does | Columns |
|---|---|---|
Uses one of two transformers, depending on whether a column has a given value. Can take several columns. |
Any |
|
Computes values from other columns with an expression, such as a unit conversion. |
Numeric, date |
|
Writes values from a list in order, and starts again at the end of the list unless |
Any |
|
Runs your own JavaScript, for one or several columns. See Scripting Transformer. |
Any |
Consistent values
Eight generators take consistent_with_column: person_generator, address_generator, finance_generator, date_generator, uuid_generator, continuous_generator, quantile_generator and formatted_string_generator. Rows with the same value in the named column get the same output.
The default, self, makes the output depend on the column’s own input value. In masking, the same input then always gets the same output.
See also
-
All Transformers: every parameter, with examples.
-
Mask a Database: choosing transformers for a masking workflow.
-
Column transformations: the keys around
params.