User GuidesAPI ReferenceRelease Notes
Doc HomeHelp CenterLog In

Writing Transformation Scripts

Use the Script option in the transformation editing dialog to create scripts that consist of statements.

The Script option is a flexible tool for defining transformations. Scripts have a text-based, statement-oriented syntax.

While other transformation editor options limit you to a single type of statement, SELECT *, you can use scripts to run any statement.

The following example shows a simple script in the transformation editor:

873

Color-coding the components of a simple script in the transformation editor.

The transformation editor uses color-coding to help you parse a script more easily:

  • Statement names appear in pink font.
  • Function names appear in blue font.
  • Attribute (also referred to as column) names appear in green font.
  • Punctuation and other syntax characters appear in black font.

Best Practices for Writing Scripts

These suggestions can help make your scripts easier to read and collaborate on.

  • Begin every script with a brief comment that describes the goal of the script. To indicate a comment, start the line with //.
  • When you define your unified dataset, use a consistent format for attribute names. For example, always use "camelCase" or "snake_case". In the transformation editor, attribute names are case sensitive.
  • in SELECT statements, include a line break after each AS attribute_name.
  • When writing nested transformations, consider using multiple spaces to indent and visually divide the script into sections.
  • The syntax for transformations (other than attribute names) is case insensitive; however, Tamr recommends writing statement names in all uppercase and function names in all lowercase as a best practice. Following this practice can make it easier to disambiguate the FILTER statement from the filter() function, for example.

Tips

These suggestions can help you use the transformation editor more effectively when working with scripts.

  • To view long scripts, expand the script box to open a larger editing area. To go back to the original area, choose Collapse.
  • To comment or uncomment lines of code, use Cmd+/ (Mac) or Ctrl+/ (Windows).
  • Multi-line comments can be written using the syntax /* My long comment */
  • To view an attribute's data type, move your cursor over the attribute name.
  • To view a function's signature, move your cursor over the function name.
  • To learn how to use a function, Cmd+click (Mac) or Ctrl+click (Windows) on the function name to open a description in a new browser tab.
2432

An expanded script box.