How Generation Works
Generation creates new rows instead of copying them. The engine learns what each column of the input looks like, then samples new values that follow it, at any size you need. The output keeps the schema and the relationships between tables.
What the engine learns
In a table in GENERATION mode, each column gets a generator, and most generators fit their parameters to the input when you don’t give them:
| Generator | What it learns or uses |
|---|---|
|
The distribution of a numeric column: mean, spread, range or bins |
|
The distribution of a date column |
|
The categories in a column and how often each appears |
|
No input values: they produce realistic names, addresses and financial values. With |
|
A pattern or a sequence, for codes and IDs |
You can give any generator its parameters instead, for example the categories and weights of a status column, or a range for amounts. That’s how you add values the input doesn’t have, such as edge cases for tests. See Generation Transformers.
If no rule gives a column a generator, the safety mode decides: STRICT stops the run; RELAXED uses a null_generator or a categorical_generator.
The output size
| Setting | Output |
|---|---|
|
A multiple of the input table’s size. Unlike masking, it can be above 1: |
|
An exact number of rows. Generation only. It overrides |
Set them in default_config for every table, or per table, for example to generate a large orders table for a performance test while the lookup tables stay small.
Keys and relationships
Keys are generated so that the output holds together:
-
Primary keys get unique values.
-
Foreign keys get the primary key of an existing parent row. The engine adds a
foreign_key_generatorfor them; you don’t set it up. -
How many children each parent gets follows a Poisson distribution by default, set from the numbers of parent and child rows. The foreign key generator also has an
ORIGINALdistribution, which approximates the input’s ratio of children to parents and takes more computation, andROUND_ROBIN, which spreads children evenly. See Foreign key distribution.
As with every mode, tables are generated parents first. See What a run does.
Privacy
Generated values are sampled, not copied, with two exceptions. A categorical_generator with categories learned from the input outputs real values from the input: that’s what you want for a status or a country code, and what you don’t want for a name or an account number. And with safety_mode: RELAXED, a column that holds one value in every row gets a constant generator with that value. Check which columns get these, especially with RELAXED.
Generation or masking?
| Masking | Generation | |
|---|---|---|
Rows |
The input’s rows, with values replaced |
New rows |
Size |
The same, or smaller |
Any size |
Values |
Real where you keep them, masked elsewhere |
Sampled from what the engine learned, or from parameters you give |
Best for |
Copies of production for development and testing, where real record combinations matter |
Performance and load tests, new features without production data, and data with no link to real records |
Related pages
-
Generating Data: step-by-step guides.