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:
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.
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.
SELECTstatements, include a line break after each
- 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.
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.
Updated about 1 month ago