Skip to main content
Supports any JS script using ECMAScript 2023 syntax. The script should have a return clause returning either a value or null / undefined. The script has access to a row object that represent a row in the dataset and have the column names as keys. Lists are supported both as inputs and outputs. It’s important to correctly manage null values by checking for null (e.g. if (row.col != null) { ... }) or using the JS optional chaining operator (?).

Usage

The following examples show how the step can be used in a recipe.

Examples

  • Example 1
  • Example 2
  • Example 3
  • Example 4
  • Example 5
  • Example 6
  • Signature
The following example joins all values in a list of numbers with ’|’ as separator:
derive_column(ds, {
  "script": "return row.numCol?.join(' | ');",
  "type": "text"
}) -> (ds.new_col)

Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally columns (ds.first_name), datasets (ds or ds[["first_name", "last_name"]]) or models (referenced by name e.g. "churn-clf").
ds
dataset
required
An input dataset.
new_col
column
required
The column resulting from evaluating the script.

Configuration

The following parameters can be used to configure the behaviour of the step by including them in a json object as the last “input” to the step, i.e. step(..., {"param": "value", ...}) -> (output).

Parameters

script
string
required
The javascript code to execute.
  • For example, to multiply by 2 every row with a value:
"return row.num * 2;"
type
string
required
Output column type. Select the desired type using a shortened yet fully specified name.Values must be one of the following:boolean category date number text url list[number] list[category] list[url] list[date] list[boolean]
I