GENERATOR

In a data query, you can use the GENERATOR operator to generate a stream of values. You can either generate a range of generated values or specify a list of explicit values manually.

Tip: This operator is useful when you want to quickly generate a dataset to feed your data queries or data fusions in Data Perspective Studio, without creating files and indexing data in Data Factory Studio.

This page discusses:

See Also
Expression Language
Defining Data Queries
RESULT SET
Data Query Views

General Parameters

Parameter Description
Label

Specify the label to display below the operator type in the data query.

Description

Add a description to display as tooltip on hover over the operator icon.

Tip: It is useful to explain what the operator does, especially when you share the data query with other users.

Generate a Range of Numeric or Date Values

The Range Strategy generates a list of values between a Start inclusive value (it includes the first value) and an End exclusive value (it excludes the last value), based on a Step to increment values.

You can define a range of:

  • Numeric values: Integer, Float, or Decimal values. If the value is numeric, the Step is also numeric.
  • Dates: Date or LocalDateTime values.

    If the value is a date, the Step can be:

    • A Period, which takes the calendar into account to calculate the step between dates. The goal is to handle relative time intervals.
    • A Duration, which does not take the calendar into account but increments dates with n seconds. The goal is to unify units of absolute time intervals.

Optionally, you can transform the output values by defining an Output expression. This expression has a unique variable called value.

Note: If the order of values in the output of the generator has no importance, you can clear the Keep order check box for better performance (it gives a better dispatching of data in multithreading).

Example 1: To generate a range of float values from 1.0 to 4.0, separated with a step of 0.5, you can define:

  • Start inclusive: 1.0
  • End exclusive: 4.0
  • Step: 0.5

In the output, you get 6 float values: 1.0, 1.5, 2.0, 2.5, 3.0, and 3.5.

Example 2: To calculate and return the cosinus for each value of a range, you can define Math.cos(value) as Output expression.

For the parameters defined in Example 1, the output returns: 0.5403023058681398, 0.0707372016677029, -0.4161468365471424, -0.8011436155469337, -0.9899924966004454, and -0.9364566872907963.

Example 3: To generate a range of dates with a step of 7 days, between March 26, 2024 and April 26, 2024, you can define:

  • Start inclusive: Date.of(year: 2024, month: 3 , day: 26 )
  • End exclusive: Date.of(year: 2024, month: 4 , day: 26)
  • Step: Period.of(days:7)

In the output, you get the following date values: 2024-03-26, 2024-04-02, 2024-04-09, 2024-04-16, and 2024-04-23.

Example 4: To generate a range of LocalDateTimes with a step of 4 hours, between April 2, 2024 18:30:00 and April 3, 2024 07:15:00, you can define:

  • Start inclusive: LocalDateTime.of(2024, 4, 2, 18, 30, 0)
  • End exclusive: LocalDateTime.of(2024, 4, 3, 7, 15, 0)
  • Step: Duration.of(hours: 4)

In the output, you get the following values: 2024-04-02 18:30:00, 2024-04-02 22:30:00, 2024-04-03 02:30:00, and 2024-04-03 06:30:00.

Enter a Set of Values with a List Expression

The Iterate over List Strategy strategy creates a flow using a list defined in the List expression.

For example, the following List expression returns 3 fields country, team, and teamcount.

Important: Surround string values with "" double quotes and numeric values without quotes.
[{country:"France",team:"Development",teamCount:60},
{country:"United Kingdom",team:"Sales",teamCount:5},
{country:"Germany",team:"Development",teamCount:20},
{country:"USA",team:"Marketing",teamCount:20},
{country:"India",team:"Development",teamCount:80},
{country:"Japan",team:"Sales",teamCount:5},
{country:"China",team:"Sales",teamCount:6},
{country:"Australia",team:"Sales",teamCount:4}]

The following Table visualization shows the data generated out of the List expression defined above (after the GENERATOR has been linked to a RESULT SET operator with a View calling all the Fields).



Output

A stream containing n values in output.