dbt-labs/dbt-core · error

get_csv_data requires agate_table argument

Error message

get_csv_data requires agate_table argument

What it means

`adapter.get_csv_data(agate_table)` serializes an agate table to CSV text. The dispatcher first checks that at least one positional argument was supplied; if `args` is empty it raises `MissingArgument` with this message, because the method cannot produce CSV without a table.

Source

Thrown at crates/dbt-adapter/src/adapter/mod.rs:4364

                }
            }
            "check_incremental_schema_changes" => {
                // on_schema_change: str, existing: Relation, target_sql: str, materialization: str = 'incremental', query_settings: dict = None -> ClickHouseColumnChanges | none
                self.check_incremental_schema_changes(state, args)
            }
            "filter_settings_by_engine" => {
                // model: dict, settings: str -> str
                Ok(args.get(1).cloned().unwrap_or_else(|| Value::from("")))
            }
            "get_ch_database" => {
                // schema: str -> str (CH database = schema in 2-part naming)
                Ok(args.first().cloned().unwrap_or_else(|| Value::from("")))
            }
            "get_csv_data" => {
                let table = args
                    .first()
                    .ok_or_else(|| {
                        minijinja::Error::new(
                            minijinja::ErrorKind::MissingArgument,
                            "get_csv_data requires agate_table argument",
                        )
                    })?
                    .downcast_object::<AgateTable>()
                    .ok_or_else(|| {
                        minijinja::Error::new(
                            minijinja::ErrorKind::InvalidOperation,
                            "get_csv_data: argument must be an AgateTable",
                        )
                    })?;
                self.get_csv_data(table)
            }
            "get_credentials" => self.get_credentials(args),
            "render_equals" => {
                let iter = ArgsIter::new(name, &["expr1", "expr2"], args);
                let expr1 = iter.next_arg::<&str>()?;
                let expr2 = iter.next_arg::<&str>()?;

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Pass the agate table as the first positional argument: `adapter.get_csv_data(agate_table)`.
  2. In custom macros, make sure the `agate_table` parameter is declared and forwarded, not shadowed or dropped.
  3. Check the macro's dispatcher (`adapter.get_csv_data` calls in the adapter's included macros) to confirm the argument order matches the Rust side.

Example fix

// before (Jinja)
{% set csv = adapter.get_csv_data() %}
// after
{% set csv = adapter.get_csv_data(agate_table) %}
Defensive patterns

Strategy: validation

Validate before calling

{# Jinja: check the argument exists before calling #}
{% if agate_table is not defined %}
  {{ exceptions.raise_compiler_error("agate_table is required for adapter.get_csv_data") }}
{% endif %}
{% set csv = adapter.get_csv_data(agate_table) %}

Type guard

{# Jinja #}
{% set ok = agate_table is defined and agate_table is not string and agate_table is not mapping %}

Prevention

When it happens

Trigger: Calling `adapter.get_csv_data()` with zero arguments from a Jinja macro (e.g. `get_csv_data()` instead of `get_csv_data(table)`), or a macro dispatching the call after dropping/failing to forward its `agate_table` parameter.

Common situations: Custom seed/loading macros copied from an older dbt release where the signature differed; macro helper functions that conditionally forward arguments and end up passing none; typos so the table argument is bound to a keyword the dispatcher ignores.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/0d71da9ef5bec7be. Report an issue: GitHub.