D toc |
---|
Excerpt | ||||
---|---|---|---|---|
In
|
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
Info NOTE: In macros, Rename Columns transformations do not work. This is a known issue.
- You cannot create macros in flows that you do not own.
- Parameter 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:
D s config Locate the following parameter:
Code Block "feature.macros.enabled": true,
Export and import of macros is controlled by a separate parameter. Locate the following parameter and set it to
true
:Code Block "feature.macros.exportable": true,
- 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:
- For the recipe on which you are working, create a new recipe.
- In this new empty recipe, add the steps to configure your headers according to the above requirements.
- No spaces. Underscores are ok:
D trans p03Value ' ' Type ref p05Name Match all occurrences p01Name Option p01Value Find and replace p02Name Columns p02Value * p05Value true p03Name Find p04Value '_' p04Name Replace with SearchTerm Rename columns based on a pattern
- No spaces. Underscores are ok:
- Select the above step. In the context menu for it, select Create macro....
- Enter a Name and optional Description value. Click Next.
- In the Create Macro dialog, you can review the step and its specified field values.
- To save the macro, click Save.
- 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
- For the recipe on which you are working, create a new recipe.
- In this new empty recipe, add the following steps.
- Redact social security numbers:
D trans Type ref p01Name Columns p01Value * p02Name Formula p02Value IF(ISVALID($col,'SSN'),'##REDACTED##',$col) SearchTerm Edit formula Redact credit card numbers: For this one, you can use the following transformation to mask the numbers except for the last four digits using
:D s item item patterns D trans p03Value XXXX-XXXX-XXXX-$1 Type ref p01Name Columns p01Value * p02Name Find p02Value `{start}{digit}{4}{any}{digit}{4}{any}{digit}{4}{any}({digit}{4}){end}` p03Name Replace with SearchTerm Replace text or patterns Info 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.
- Redact social security numbers:
- Select the above steps. In the context menu for it, select Create macro....
- Enter a Name and optional Description value. Click Next.
- In the Create Macro dialog, you can review the step and its specified field values.
- 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.
- 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
- To save the macro, click Save.
- 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 a Macro.
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:
Info |
---|
NOTE: When a flow is shared, its macros are also shared with the collaborators on the flow. All of the macros owned by the creator of the flow are also shared with collaborators. |
Collaborator can use or modify the macro in the shared flow. Any of the flow owner's macros can be used in other recipes.
Import/Export
Info |
---|
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.