Expression Generator
About
A expression generator is a column data generator that can generate data created from:
- other columns (known as parent columns)
- by giving an expression (or formula).
Howto
Syntax
columns:
- name: columnName
DataGenerator:
type: expression
ColumnParents:
- columnParentName1 # variable x
- columnParentName2 # variable y
- ...... # variable "z", "a", "b", "c", "d","e","f"
expression: "javascriptExpression" # See below for example
Mandatory Key | Description |
---|---|
ColumnParents | The column generator used in the expression |
expression | The expression in javascript where the parents columns maps by order to the following variables “x”, “y”, “z”, “a”, “b”, “c”, “d”,“e”, “f” |
How to hide intermediate columns ?
When creating an expression generator, you may want to create columns that should not appear in the data generated. For this purpose, you can use the hidden property.
Example:
- name: columnToHide
Hidden: true # The column will not be added to the output.
Description: An hidden column
DataGenerator:
type: entity
Snippet of expression
This section is showing snippet of expression (Javascript).
Time
- Month where x represents the date value of the first parent columns
x.getMonth()+1 // Month
- Month names. The below snippet use a date column as parent and lookup an array to get the month name.
var monthNames = ['Jan', 'Feb', 'Maa', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'];
monthNames[x.getMonth()]
- Year number
x.getFullYear()
Email String concatenation where:
- x would be a name from the first parent column
- y would be a company name from the second parent column
- z would be a TLD domain extension (.com, …)
x+'@'+y+'.'+z
Data Type
The below data type are supported:
Data Type |
---|
Integer |
Float |
Double |
Numeric |
Decimal |
Date |
Timestamp |
Varchar |