{"record":{"id":"f845a684951d3c07","repo":"dbt-labs/dbt-core","slug":"get-csv-data-argument-must-be-an-agatetable","errorCode":null,"errorMessage":"get_csv_data: argument must be an AgateTable","messagePattern":"get_csv_data: argument must be an AgateTable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/adapter/mod.rs","lineNumber":4371,"sourceCode":"                // model: dict, settings: str -> str\n                Ok(args.get(1).cloned().unwrap_or_else(|| Value::from(\"\")))\n            }\n            \"get_ch_database\" => {\n                // schema: str -> str (CH database = schema in 2-part naming)\n                Ok(args.first().cloned().unwrap_or_else(|| Value::from(\"\")))\n            }\n            \"get_csv_data\" => {\n                let table = args\n                    .first()\n                    .ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::MissingArgument,\n                            \"get_csv_data requires agate_table argument\",\n                        )\n                    })?\n                    .downcast_object::<AgateTable>()\n                    .ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::InvalidOperation,\n                            \"get_csv_data: argument must be an AgateTable\",\n                        )\n                    })?;\n                self.get_csv_data(table)\n            }\n            \"get_credentials\" => self.get_credentials(args),\n            \"render_equals\" => {\n                let iter = ArgsIter::new(name, &[\"expr1\", \"expr2\"], args);\n                let expr1 = iter.next_arg::<&str>()?;\n                let expr2 = iter.next_arg::<&str>()?;\n                iter.finish()?;\n                self.render_equals(state, expr1, expr2)\n            }\n            _ => Err(minijinja::Error::new(\n                minijinja::ErrorKind::UnknownMethod,\n                format!(\"Unknown method on adapter object: '{name}'\"),\n            )),","sourceCodeStart":4353,"sourceCodeEnd":4389,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/adapter/mod.rs#L4353-L4389","documentation":"When `adapter.get_csv_data(...)` receives an argument but it cannot be downcast to the internal `AgateTable` object type, the dispatcher raises this `InvalidOperation` error. The method only understands real agate-table wrapper objects produced by the seed-loading pipeline, not plain strings, dicts, or other Value types.","triggerScenarios":"Calling `adapter.get_csv_data(x)` where `x` is a string path to a CSV, a dict, a Jinja list, or any Value that is not an `AgateTable` object — for example passing `config.get('seed_path')` or the text output of another call instead of the loaded table.","commonSituations":"Custom macros that load CSV contents themselves and pass the raw string; confusion between a seed's file path and its parsed table; macros ported from dbt-core where the table was a Python agate object but here must be the engine's AgateTable wrapper.","solutions":["Pass the actual agate table object (typically the `agate_table` variable in seed macros), not a path string or dict.","If you only have a CSV file, load it through the engine's seed-loading path to obtain an AgateTable before calling get_csv_data.","Log/type-check the argument with `is mapping` / `is string` tests in Jinja to catch wrong inputs before dispatching."],"exampleFix":"// before (Jinja)\n{% set csv = adapter.get_csv_data(seed_file_path) %}\n// after\n{% set csv = adapter.get_csv_data(agate_table) %}","handlingStrategy":"type-guard","validationCode":"{# Jinja: string path or mapping means you don't have a table object #}\n{% if agate_table is string or agate_table is mapping %}\n  {{ exceptions.raise_compiler_error(\"get_csv_data needs an AgateTable, not a path/dict\") }}\n{% endif %}","typeGuard":"{# Jinja: AgateTable is an opaque object; reject obvious non-tables #}\n{% set looks_like_table = agate_table is defined and agate_table is not string and agate_table is not mapping and agate_table is not sequence %}","tryCatchPattern":null,"preventionTips":["Obtain tables only from the seed-loading pipeline (the `agate_table` macro variable), not from file paths.","Don't pass strings, dicts, or lists to adapter methods typed for table objects.","When porting Python macros, replace agate-specific values with the engine's AgateTable wrapper."],"tags":["jinja","type-mismatch","csv","argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}