Skip to content
background-image background-image

Data transformation

This example shows how to easily transform input data into another structure.

Motivation

Suppose we have list of users (FirstName + LastName) and we have to derive a new column named FullName based on them.

Input schema

Column Data type
FirstName string
LastName string

Input data

FirstName LastName
Alice Smith
Bob Johnson

Ouput schema

Column Data type
FirstName string
LastName string
FullName string

JavaScript statement

var output = inputData.map(function(user) {             // transforming function applied to each input record
    return {                                            // returns transformed record
      FirstName:user.FirstName,                         // copied Firstname from input
      LastName: user.LastName,                          // copied Lastname from input
      FullName: user.FirstName + '' '' + user.LastName  // new derived property created by combination of Firstname and Lastname 
    };
});

return output;                                          // returning re-mapped array

Output data

FirstName LastName FullName
Alice Smith Alice Smith
Bob Johnson Bob Johnson