{"record":{"id":"4f261ed8359036fe","repo":"dbt-labs/dbt-core","slug":"show-tables-results-must-contain-agatetables","errorCode":null,"errorMessage":"show_tables_results must contain AgateTables","messagePattern":"show_tables_results must contain AgateTables","errorType":"exception","errorClass":"minijinja::Error::InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/adapter/mod.rs","lineNumber":560,"sourceCode":"    /// ```\n    #[tracing::instrument(skip_all, level = \"trace\")]\n    pub fn build_catalog_from_show_tables_and_svv_columns(\n        &self,\n        _state: &State,\n        args: &[Value],\n    ) -> Result<Value, minijinja::Error> {\n        match &self.inner {\n            Typed { adapter, .. } => {\n                let iter = ArgsIter::new(\n                    \"build_catalog_from_show_tables_and_svv_columns\",\n                    &[\"show_tables_results\", \"svv_columns\"],\n                    args,\n                );\n                let show_tables_value = iter.next_arg::<&Value>()?;\n                let mut show_tables_results: Vec<Arc<AgateTable>> = Vec::new();\n                for table_value in show_tables_value.try_iter()? {\n                    let table = table_value.downcast_object::<AgateTable>().ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::InvalidOperation,\n                            \"show_tables_results must contain AgateTables\",\n                        )\n                    })?;\n                    show_tables_results.push(table);\n                }\n                let svv_columns = iter\n                    .next_arg::<&Value>()?\n                    .downcast_object::<AgateTable>()\n                    .ok_or_else(|| {\n                        minijinja::Error::new(\n                            minijinja::ErrorKind::InvalidOperation,\n                            \"svv_columns must be an AgateTable\",\n                        )\n                    })?;\n                iter.finish()?;\n\n                let catalog = adapter.build_catalog_from_show_tables_and_svv_columns(","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/adapter/mod.rs#L542-L578","documentation":"`build_catalog_from_show_tables_and_svv_columns` iterates the `show_tables_results` argument expecting every element to be an AgateTable. This error is thrown when any element of that iterable cannot be downcast to `Arc<AgateTable>`. It protects the catalog builder from receiving dicts or other serialized data in the show-tables list.","triggerScenarios":"Calling build_catalog_from_show_tables_and_svv_columns with a show_tables_results list that contains non-AgateTable items — e.g. plain dicts from a custom `show_tables` macro or a partially serialized results array.","commonSituations":"Redshift catalog ingestion where a custom show-tables override returns raw rows; mixing parsed and unparsed result sets when assembling the catalog arguments from Python.","solutions":["Ensure each entry in show_tables_results is converted via load_agate_table()/AgateTable before being passed","Check that the list is not accidentally a single table wrapped in the wrong nesting level (e.g. list of dicts instead of list of tables)","Log the element type at the failing index to confirm which item is not an AgateTable"],"exampleFix":"// before\nshow_tables_results = res['tables']  # list of dicts\n// after\nshow_tables_results = [load_agate_table(t) for t in res['tables']]","handlingStrategy":"validation","validationCode":"# ensure every element is an agate table before the call\nassert all(hasattr(t, 'column_names') for t in show_tables_results), 'every show_tables_result must be an agate Table'","typeGuard":"fn all_agate_tables(v: &Value) -> bool {\n    v.try_iter().map(|it| it.all(|x| x.downcast_object::<AgateTable>().is_some())).unwrap_or(false)\n}","tryCatchPattern":"match table_value.downcast_object::<AgateTable>() {\n    Some(t) => show_tables_results.push(t),\n    None => return Err(minijinja::Error::new(minijinja::ErrorKind::InvalidOperation,\n        \"show_tables_results must contain AgateTables; convert each item with load_agate_table()\")),\n}","preventionTips":["Convert each show-tables result set to an AgateTable at collection time","Test custom catalog macros against the built-in macro output shape","Avoid mixing raw dicts and parsed tables in the results list"],"tags":["catalog","agate","downcast","redshift"],"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"}