Control / subflow · All operations
Define a reusable macro or function
A variant of Call a reusable workflow
Write a parameterised macro or function once and call it from many queries or flows.
Status
- In arcform
Not built yet
arcform does not do this yet; it would live in how a Protocol runs. Its place on the roadmap
What other tools call it
Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).
AWS Glue (1)
Custom visual transformsread 2026-09-27User-built transforms, uploaded to Amazon S3, that then appear as nodes in the visual editor
Azure Data Factory (1)
User defined functionsread 2026-09-27Reusable custom expression functions, kept in libraries and shared between data flows
Bruin (1)
Macros (user-defined)read 2026-09-27User Jinja macros in a macros/ directory, loaded automatically and called from SQL assets
DuckDB (1)
CREATE MACROread 2026-09-27Define a reusable scalar or table macro in SQL
Polars (2)
DataFrame.piperead 2026-09-27Pass the frame through a user function so custom steps chain like methods
LazyFrame.pipe_with_schemaread 2026-09-27Pass the lazy frame and its resolved schema to a user function at planning time
Power Query M (1)
Function valuesread 2026-09-276 functions: Function.Invoke, Function.InvokeAfter, Function.From, Function.ScalarVector, Function.IsDataSource
RapidMiner Studio (2)
Custom Subprocessread 2026-09-27Define a custom operator that exposes subprocesses to its user
Metadata Helperread 2026-09-27Define the output metadata of a custom operator via a subprocess, leaving data unchanged
SQLMesh (1)
Jinja macrosread 2026-09-27Jinja templating and user macro functions as the alternative macro system
Background
In DuckDB, the CREATE MACRO statement defines a named, callable Structured Query Language (SQL) expression as a database schema object.[1] A parameterised macro is able to insert given objects into its expansion, which gives the macro some of the power of a function.[2] In Bruin, macros are reusable pieces of Jinja code that define SQL patterns once for use throughout a pipeline.[3]
When to use it
In Azure Data Factory (ADF), logic built repeatedly in expressions across multiple mapping data flows is a good opportunity for a user defined function.[4] In Bruin, simple patterns might not need a macro, and some complex macros might impact query performance.[3]
In DuckDB, a macro parameter's default value is in principle evaluated when the macro is defined, not when it runs.[1] In DuckDB, an = in a macro call is read as a comparison rather than a named parameter, so named parameters are passed with :=.[1] In DuckDB, defining a recursive macro is not supported.[1] In Bruin, SQL comments do not prevent Jinja from processing macros, so a macro call inside a comment still executes.[3] In ADF, a user defined function cannot refer to another user defined function.[4]
The method
Applying a macro to an input is known as macro expansion.[2] In DuckDB, a macro call is expanded: the macro is replaced with its expression, and the parameters in it are replaced with the supplied arguments.[1] In DuckDB, a scalar macro evaluates to a scalar value, while a table macro returns a tabular result and acts essentially as a table function.[1] In DuckDB, a macro can be overloaded on the types or the number of its parameters, with every implementation defined in the same CREATE MACRO statement.[1]
In Bruin, all macros defined in the pipeline's macros/ folder are loaded automatically and can be used anywhere without explicit imports.[3] In Bruin, the bruin render command shows exactly what macros generate.[3] In ADF, user defined functions live in a collection called a data flow library, and each can take zero or more arguments.[4]
Compared with the alternatives
In DuckDB, the CREATE FUNCTION statement is an alias for CREATE MACRO.[1]
Sources
- [1]CREATE MACRO Statement – DuckDBdocumentation
- [2]Macro (computer science)secondary source
- [3]Macros | Bruin CLIdocumentation
- [4]User defined functions in mapping data flows - Azure Data Factory & Azure Synapse | Microsoft Learndocumentation