Expression Generator
About
A expression data-supplier is a column data supplier that can generate data created from:
- other columns (known as parent columns)
- by giving an expression (or formula).
Example
Syntax
columns:
- name: column_name
data-supplier:
type: expression
arguments:
# The name of a column used in the expression
column-variable: columnVariableName # becomes in the expression, the variable columnvariablename
# A list of column name used in the expression
column-variables:
- columnVariableName1 # becomes in the expression, the variable columnvariablename1
- columnVariableName2 # becomes in the expression, the variable columnvariablename2
- ......
# The expression
expression: "javascriptExpression"
Arguments
The arguments of the data supplier node are:
| Name | Description |
|---|---|
| column-variable | A column name used in the expression as variable |
| column-variables | A list of column names used in the expression as variables |
| expression | The expression |
What are Expressions ?
Expressions are Javascript expressions.
Tabulify pass the data as native javascript data type in a variable with the name of the column in lowercase. You don't need to instantiate the variables, Tabulify do.
Note:
- For date/timestamp/time data type, we create a Date as this is the only temporal data type of javascript.
- For all numbers (Double, Integer, …) , we create a Number as this is also the only number data type of javascript.
Example for 2009/10/01 and the column name date or DATE, Tabulify would create the date variable like this:
date = new Date("2009","10","01")
And if you want the month, you expression would use getMonth :
date.getMonth()+1
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
data-supplier:
type: entity
Data Type
The below data type are supported:
| Data Type | Java script Equivalent |
|---|---|
| Integer | Number |
| Double/Float | Number |
| Numeric/Decimal | Number |
| Date/Timestamp | Date |
| Varchar/Char | String |