Expression Generator

Undraw File Manager

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:




Related HowTo
Undraw File Manager
Data Generator - How to generate a date dimension ?

A date dimension is a typical case for data generation and this article shows you how to generate it.
Undraw File Manager
How to write a Javascript expression generator?

This howto will show you how to write an expression for a expression generator. An expression generator generates data from another column based on an expression. This example generate a times table...
Undraw File Manager
Learning Tabulify - Step 9 - How to fill a data resource with generated data ?

Tabulify integrates natively a data generator. You can generate realistic production data and start working on your project right away. anonymize production data in your development environment because...
Undraw File Manager
Tabulify - How to fill a database relational schema with generated data and Tabul

This how-to will show you how to use the tabul fill command to fill all the tables of a schema with generated data.

Task Runner