A Decorator Data Block in Assette is a specialized block used to apply supplemental logic, transformations, or configuration settings to data before it is processed by its dependent blocks. Decorator Blocks act as pre-processors, ensuring that certain operations are consistently applied across multiple data flows without duplicating logic within individual Data Blocks.
By design, Decorator Blocks do not serve as primary data sources. Instead, they intercept the data flow to enrich, transform, or configure the data before it is passed downstream. They are particularly useful when the same processing or preparation needs to be applied to multiple Data Blocks.
Purpose and Use Cases #
The primary role of a Decorator Data Block is to provide a reusable mechanism for applying standard logic across multiple data processing workflows. Common use cases include:
- Applying consistent transformations to datasets, such as formatting, field normalization, or data type conversions.
- Injecting configuration values or parameters required by multiple dependent blocks.
- Performing pre-processing calculations such as adding computed fields, applying filters, or enforcing business rules.
- Setting execution context so that downstream Data Blocks operate with a consistent set of parameters or assumptions.
This approach ensures standardization, reduces duplication of logic, and improves maintainability.
Execution Behavior #
When a Decorator Data Block is added as a dependency to any Data Block, the Decorator Block will always execute before the dependent Data Block, regardless of its position in the dependency list. This ensures that any pre-processing or transformation is completed before the main data operations begin.
Using Multiple Decorator Blocks #
It is possible to use multiple Decorator Blocks. When doing so, the execution order is determined either by the order in which they are listed as dependencies or by explicitly defining dependencies between the Decorator Blocks themselves.
If order is critical between Decorator Blocks, it is recommended to explicitly declare one Decorator Block as a dependency of the other to ensure the correct sequence.
Passing Parameters to Decorator Blocks #
Decorator Blocks can receive parameters from upstream blocks, allowing them to adapt their behavior based on prior processing steps. This parameter passing is particularly useful when:
- The Decorator Block’s logic depends on calculated values or state from an earlier block.
- Contextual information (such as date ranges or user selections) needs to be applied before the main processing occurs.
- The Decorator Block is used in multiple contexts and requires dynamic configuration.
For example, a parameter could be computed in a setup block, passed into the Decorator Block, and then used to filter or transform data before passing it on to a Data Block.
Best Practices #
To make effective use of Decorator Data Blocks:
- Keep Decorator logic modular so it can be reused without modification.
- Pass only the parameters necessary for the Decorator Block’s operation to keep it flexible and maintainable.
- When stacking multiple Decorator Blocks, define dependencies explicitly to avoid unintended execution orders.
- Use Decorator Blocks for pre-processing and standardization, not for primary data retrieval.