Skip to main content

random_choice

Replace values randomly chosen from a provided list.

Parameters

NameDescriptionDefaultRequiredSupported DB types
columnThe name of the column to be affectedYesany
valuesA list of values in any format. The string with value \N is considered NULL.Yes-
validatePerforms a decoding procedure via the PostgreSQL driver using the column type to ensure that values have correct typetrueNo
keep_nullIndicates whether NULL values should be replaced with transformed values or nottrueNo
engineThe engine used for generating the values [random, hash]. Use hash for deterministic generationrandomNo-

Description

The RandomChoice transformer replaces one randomly chosen value from the list provided in the values parameter. You can use the validate parameter to ensure that values are correct before applying the transformation. The behaviour for NULL values can be configured using the keep_null parameter.

The engine parameter allows you to choose between random and hash engines for generating values. Read more about the engines in the Transformation engines section.

Example: Choosing randomly from provided dates

In this example, the provided values undergo validation through PostgreSQL driver decoding, and one value is randomly chosen from the list.

RandomChoice transformer example
- schema: "humanresources"
name: "jobcandidate"
transformers:
- name: "RandomChoice"
params:
column: "modifieddate"
validate: true
engine: hash
values:
- "2023-12-21 07:41:06.891"
- "2023-12-21 07:41:06.896"

Result

ColumnOriginalValueTransformedValue
modifieddate2007-06-23 00:00:002023-12-21 07:41:06.891
Copyright © GreenMask 2026