MACRO()
All functions > CORE > MACRO()
Returns a reference to a macro of the given feature with the given inputs.
Signatures
Returns: A macro feature with parameterized inputs
MACRO(base: FEATURE, inputs: ARRAY<FEATURE>) → FEATURE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
base | FEATURE | Yes | The base feature to create a macro from |
inputs | ARRAY<FEATURE> | Yes | Array of input features to parameterize the macro |
Notes
- Creates a reusable macro from a feature with input parameters
- Macros allow features to be parameterized and reused
- Input array specifies which inputs the macro accepts
- Enables creating template features that can be instantiated with different inputs
- Part of the FeatureMesh core system for feature reusability
Examples
MACRO(...) USING inputs (4-udfs-base.slt)
FeatureQL
WITH
DATE_INPUT := INPUT(DATE),
NORMALIZED_QUARTER := MACRO(
EXTRACT_FROM_DATE(DATE_INPUT, 'YEAR')::VARCHAR || 'Q' || EXTRACT_FROM_DATE(DATE_INPUT, 'QUARTER')::VARCHAR
USING DATE_INPUT
)
SELECT
QUARTER_FROM_DATE := NORMALIZED_QUARTER(DATE '2025-08-15'),
QUARTER_FROM_TIMESTAMP := TIMESTAMP '2025-10-15 14:30:00'::DATE.NORMALIZED_QUARTER()
;Result
| QUARTER_FROM_DATE VARCHAR | QUARTER_FROM_TIMESTAMP VARCHAR |
|---|---|
| 2025Q3 | 2025Q4 |