arguments (for macros)
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 resource can accept. Each argument can have a name, a type field, and an optional description.
For macros, you can add arguments to a macro property, which helps in documenting the macro and understanding what inputs it requires.
type
(Applies to dbt v1.10 and later)The data type of your argument. Setting validate_macro_args to true ensures that documented macro argument names match those in the macro definition and validates their types against the supported types. When set to false, type is only used for documentation purposes and there are no restrictions on the values you can specify.
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:
- 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:
stringorstrbooleanorboolintegerorintfloatanylist[<Type>], for example,list[string]dict[<Type>, <Type>], for example,dict[str, list[int]]optional[<Type>], for example,optional[integer]relationcolumn
Note that the types follow a Python-like style but are used for documentation and validation only. They are not Python types.
Examples
{% macro cents_to_dollars(column_name, scale=2) %}
({{ column_name }} / 100)::numeric(16, {{ scale }})
{% endmacro %}
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."
Related documentation
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.