Skip to main content

Scripting in Data Prep

In the Data Prep node you can add custom calculated columns using scripting expressions. Each expression receives the current row's column values and returns the value for the new column.

Column values are accessed using the prefix Col_ followed by the column name (e.g. Col_firstName, Col_orderDate).

Examples​

Concatenate First and Last Name​

Create a "Full Name" column by joining two existing columns:

Col_firstName + " " + Col_lastName

Calculate Profit​

Derive a "Profit" column from "Sales" and "Expenses":

Col_sales - Col_expenses

Parse a Date String to LocalDateTime​

Convert a string column in yyyy-MM-dd HH:mm:ss format to a LocalDateTime value:

LocalDateTimeUtil.parse(Col_orderDate, "yyyy-MM-dd HH:mm:ss")

Extract the Quarter from a Date​

Return the quarter (Q1–Q4) based on the month of a LocalDateTime column:

var month = LocalDateTimeUtil.getMonth(Col_orderDate);
if (month <= 3) { "Q1"; }
else if (month <= 6) { "Q2"; }
else if (month <= 9) { "Q3"; }
else { "Q4"; }

Reformat a Date String​

Parse an ISO-8601 timestamp string (e.g. 2023-10-25T12:22:05.2247439Z) into a LocalDate:

var instant = Instant.parse(Col_datetime);
var year = InstantUtil.getYear(instant);
var month = InstantUtil.getMonth(instant);
var day = InstantUtil.getDayOfMonth(instant);
LocalDate.of(year, month, day);
  • Data Prep Node — full reference for the Data Prep transformation node.
  • Types & Objects — LocalDate, LocalDateTime, Instant, and other types used in expressions.
  • Utilities — all available utility classes (LocalDateTimeUtil, InstantUtil, etc.).