Creating a custom transformation

You can create a custom transformation by writing custom Groovy code in the Transformation Editor. After you save the custom transformation, it is added as one individual execution step to the transformation script.

The Transformation Editor provides access to lists of functions and attributes to insert into a transformation script. The individual Groovy functions are documented in Transform Function Reference.

Also note that like other scripting languages, Groovy has a set of reserved keywords that have special meanings and therefore can't be used as variable or function names in transformation scripts. For details, see Unsupported Groovy language features.

To create a custom transformation:

  1. In the Catalog, select a project.
  2. Select Transform.
  3. From the transform menu, select Editor.
  4. To insert the current refinement state into the script, click the Use refinement state as a conditional statement link.
  5. To insert a function into the custom transform code:
    1. Click Functions.
    2. To find a specific function, use the filter field to filter by function name, or choose a category of functions from the drop down to filter by grouping such as data type.
    3. To add a function, either double-click it, or drag and drop it into the script.
  6. To insert an attribute name into the custom transform code:
    1. Click Attributes.
    2. To find a specific attribute, use the filter field. You can filter the list by name or data type.
    3. To add an attribute, either double-click it, or drag and drop it into the script.
  7. Add any additional Groovy code as necessary for your data cleaning.
  8. If you are applying the transform to an existing attribute, select Apply transformation to [attribute name]
    Applying a transformation to the selected attribute overwrites the attribute with the transformed data.
  9. If you are creating a new attribute, provide the attribute name in Create New Attribute.
    Setting the transformation to output to a new column adds a new attribute to your project data set. The new name can only contain alphanumeric characters and underscores (_). If the name you enter contains unsupported characters, the outline of the text box turns red and you receive an error message if you try to preview or save the transformation.
  10. From the Data Type list, select the data type to assign to the resulting attribute.
    Studio automatically selects an appropriate data type, but you can override this.
  11. If the new attribute should be multi-assign, deselect the Single Assign check box.
  12. Either click Preview to see the previewed results of running the transformation, or click Add to Script to save the transformation step to the script.

If you are done making changes to the project data set, you can commit the changes. See Running the transformation script against a project data set.