{"record":{"id":"6aa81d9b21f6eb8e","repo":"dbt-labs/dbt-core","slug":"method-method-did-not-return-a-table-when-call","errorCode":null,"errorMessage":"Method '{method}' did not return a Table when called on a TableSet","messagePattern":"Method '(.+?)' did not return a Table when called on a TableSet","errorType":"exception","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table_set.rs","lineNumber":216,"sourceCode":"    /// def _proxy(self, method_name, *args, **kwargs):\n    ///     \"\"\"\n    ///     Calls a method on each table in this :class:`.TableSet`.\n    ///     \"\"\"\n    /// ```\n    fn _proxy(\n        self: &Arc<Self>,\n        state: &State<'_, '_>,\n        method: &str,\n        args: &[Value],\n        listeners: &[Rc<dyn RenderingEventListener>],\n    ) -> Result<Arc<Self>, Error> {\n        let mut tables: Vec<Arc<AgateTable>> = Vec::with_capacity(self.tables.len());\n        for table in self.tables.iter() {\n            let new_table = table\n                .call_method(state, method, args, listeners)?\n                .downcast_object::<AgateTable>()\n                .ok_or_else(|| {\n                    Error::new(\n                        ErrorKind::InvalidOperation,\n                        format!(\n                            \"Method '{}' did not return a Table when called on a TableSet\",\n                            method\n                        ),\n                    )\n                })?;\n            tables.push(new_table);\n        }\n        self._fork(tables, self.keys.clone(), None, None)\n    }\n\n    fn tables_as_tuple(self: &Arc<Self>) -> TableSetTablesAsTuple {\n        TableSetTablesAsTuple::of_tableset(self)\n    }\n\n    fn keys_as_tuple(self: &Arc<Self>) -> TableSetKeysAsTuple {\n        TableSetKeysAsTuple::of_tableset(self)","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table_set.rs#L198-L234","documentation":"AgateTableSet._proxy fans a method call out to every table in the set and expects each underlying table to return an AgateTable. If any table's method result cannot be downcast to an AgateTable, this InvalidOperation error is thrown instead of proceeding. It signals the proxied method produced a value of an unexpected type for at least one member table.","triggerScenarios":"Calling TableSet.call_method (via _proxy) with a method name whose implementation returns something other than an AgateTable (e.g. a computed column value, a scalar, or a different object type) for one of the tables in the set.","commonSituations":"Passing a jinja/agate method name that is only valid on non-table objects; a custom or patched method returning a scalar; version drift where a method's return type changed.","solutions":["Verify the method name is one that returns a Table (e.g. aggregate-style table-to-table operations), not a scalar-returning method.","Call the method on individual tables via table.call_method and inspect the returned object type before using TableSet.","If a custom method is registered, ensure it returns an AgateTable-wrapped object.","Check for version mismatches between the method registry and the TableSet proxy code."],"exampleFix":"// before\ntables.call_method(state, \"column_names\", args) // returns a list, not a Table\n// after\ntables.call_method(state, \"join\", args) // use a method that returns a Table","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// verify result is a table before use\nlet obj = table.call_method(state, method, args)?;\nif obj.downcast_object::<AgateTable>().is_none() {\n    // handle non-table result, e.g. skip or fall back to per-table calls\n}","tryCatchPattern":null,"preventionTips":["Only proxy methods documented to return a Table through TableSet.","Test new/registered methods against a TableSet, not just a single table."],"tags":["jinja","table-set","type-mismatch"],"backgroundTag":"type-mismatch","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"}