Skip to main content

Overview of Macros

In Designer Cloud Powered by Trifacta Enterprise Edition, a macro is a saved sequence of one or more recipe steps that can be reused in other recipes. As needed, values in the recipe steps can be modified, so that instances of the macro can be configured for the recipe requirements.

Limitations

  • You cannot create macros from steps that contain the following:

    • Multi-dataset operations like join, union, and lookup

    • Data-dependent transformations like header, valuestocols, and pivot.

    • Other macros

      Note

      OTE: In macros, Rename Columns transformations do not work. This is a known issue.

  • You cannot create macros in flows that you do not own.

  • Macro input limitations on the following types:

    • limits

    • enums

    • arrays

  • Sharing of macros is not supported.

    • When working with a flow that was shared with you, you can only use the macros that belong to the flow's owner.

  • When a flow containing a macro is imported, the macro steps are expanded.

Enable

This feature is enabled by default. To disable this feature, please complete the following steps.

Steps:

  1. You can apply this change through the Admin Settings Page (recommended) or trifacta-conf.json. For more information, see Platform Configuration Methods.

  2. Locate the following setting:

    "feature.macros.enabled": true,
  3. Export and import of macros is controlled by a separate setting. Locate the following setting and set it to true:

    "feature.macros.exportable": true,
  4. Save your changes and restart the platform.

Examples

Example 1 - Reformat headers

Suppose one of your downstream systems has the following requirements for column headers:

  • No spaces. Underscore is ok.

You can do the following:

  1. For the recipe on which you are working, create a new recipe.

  2. In this new empty recipe, add the steps to configure your headers according to the above requirements.

    1. No spaces. Underscores are ok:

      Transformation Name

      Rename columns based on a pattern

      Parameter: Option

      Find and replace

      Parameter: Columns

      All

      Parameter: Find

      ' '

      Parameter: Replace with

      '_'

      Parameter: Match all occurrences

      true
  3. Select the above step. In the context menu for it, select Create or replace macro.

    1. Enter a Name and optional Description value. Click Next.

    2. In the Create Macro dialog, you can review the step and its specified field values.

    3. To save the macro, click Save.

  4. For any recipe that must generate results for this downstream system, you can insert this macro as the last step before publication. For example, you can delete the recipe where you made the macro and insert the macro reference in the preceding recipe.

Example 2 - Redact data for sensitive column data types

For security reasons, you may decide that sensitive information must be redacted before it is delivered as an output for downstream consumption. For the following data types, you may wish to remove the sensitive information at the end of your transformation process:

  • Credit card numbers

  • Social Security numbers

  1. For the recipe on which you are working, create a new recipe.

  2. In this new empty recipe, add the following steps.

    1. Redact social security numbers:

      Transformation Name

      Edit formula

      Parameter: Columns

      All

      Parameter: Formula

      IF(ISVALID($col,'SSN'),'##REDACTED##',$col)
    2. Redact credit card numbers: For this one, you can use the following transformation to mask the numbers except for the last four digits using Wrangle :

      Transformation Name

      Replace text or patterns

      Parameter: Columns

      All

      Parameter: Find

      `{start}{digit}{4}{any}{digit}{4}{any}{digit}{4}{any}({digit}{4}){end}`

      Parameter: Replace with

      XXXX-XXXX-XXXX-$1

      Note

      The above transformation matches values based on the structure of the data, instead of the data type. If for some reason, you have values that are not credit card numbers yet follow the credit card pattern, those values will be masked as well by this transformation.

  3. Select the above steps. In the context menu, select Create or replace macro.

    1. Enter a Name and optional Description value. Click Next.

    2. In the Create Macro dialog, you can review the step and its specified field values.

      1. You may wish to parameterize the Find and Replace with values. For example, for some uses of the macro, you may wish to replace with an empty string or a value like ##REDACTED## like the previous macro.

    3. To save the macro, click Save.

  4. For any recipe that must generate results for this downstream system, you can insert this macro as the last step before publication. For example, you can delete the recipe where you made the macro and insert the macro reference in the preceding recipe.

Create

A macro is created from a sequence of steps inside a recipe.

  • The steps do not have to occur consecutively in the recipe.

  • Recipe steps are added to the macro in the order that they are listed in the recipe.

  • Some recipe steps cannot be added to a macro, so the option to create a macro with these types of steps is not available.

For more information, see Create or Replace Macro.

Macro inputs

When you create a macro, you can define macro inputs to contain values to be used in the macro's steps. Values for these inputs can be specified with each instance of a macro. For example, if you use MacroA at Step 2 and Step 37 of your recipe, you can specify different values for inputs to MacroA at the Step 2 and Step 37 instance of it.

  • Create macro inputs: Macro inputs can be defined when you create a new macro.

  • Reuse or replace macro inputs: When you replace a macro, you can reuse or replace the existing macro inputs in the new version of a macro.

    • If you are reusing the existing macro inputs, you must map them to the new steps in the new version of the macro.

    • If you are replacing macro inputs, instances of the macro that were added to your recipes under the old definition must be updated.

Apply

After a macro is created, you can apply an instance of it anywhere in your recipes. See Apply a Macro.

Sharing

Macros cannot be independently shared.

Copy a flow:

All macros are included. Steps are not expanded.

Share a flow:

When a flow is shared, the flow owner's macros are available for use by any collaborator in the recipes of the shared flow.

Import/Export

Note

Exported macros can be imported into a release that is later than the source release of the product. Exported macros cannot be imported into earlier releases.

Export:

  • You can export individual macros from the Macros page. See Export Macro.

  • When a flow containing a recipe that references macros is exported, macros are exported as expanded steps.

Import:

  • Exported macros can be imported into a new environment through the Macros page. See Import Macro.

  • When a flow containing macros is imported, the expanded steps are imported normally.

Manage

After macros have been created, you can manage them through the Library. For more information, see Macros Page.