arguments
macros/<filename>.yml
version: 2
macros:
  - name: <macro name>
    arguments:
      - name: <arg name>
        type: <string>
        description: <markdown_string>
Definition
The arguments property is used to define the parameters that a macro can accept. Each argument can have a name, type, and description.  You can add arguments to a macro property, which helps in documenting the macro and understanding what inputs it requires.
type
tip
From dbt Core v1.10, you can opt into validating the arguments you define in macro documentation using the validate_macro_args behavior change flag. When enabled, dbt will:
- Infer arguments from the macro and includes them in the manifest.json file if no arguments are documented.
- Raise a warning if documented argument names don't match the macro definition.
- Raise a warning if typefields don't follow supported formats.
Learn more about macro argument validation.
macros/<filename>.yml
version: 2
macros:
  - name: <macro name>
    arguments:
      - name: <arg name>
        type: <string>
Supported types
From dbt Core v1.10, when you use the validate_macro_args flag, dbt supports the following types for macro arguments:
- stringor- str
- booleanor- bool
- integeror- int
- float
- any
- list[<Type>], for example,- list[string]
- dict[<Type>, <Type>], for example,- dict[str, list[int]]
- optional[<Type>], for example,- optional[integer]
- relation
- column
Note that the types follow a Python-like style but are used for documentation and validation only. They are not Python types.
Examples
macros/cents_to_dollars.sql
{% macro cents_to_dollars(column_name, scale=2) %}
    ({{ column_name }} / 100)::numeric(16, {{ scale }})
{% endmacro %}
macros/cents_to_dollars.yml
version: 2
macros:
  - name: cents_to_dollars
    arguments:
      - name: column_name
        type: column
        description: "The name of a column"
      - name: scale
        type: integer
        description: "The number of decimal places to round to. Default is 2."
0