{"record":{"id":"2e8ff757e4b84088","repo":"dbt-labs/dbt-core","slug":"table-group-by-e","errorCode":null,"errorMessage":"Table.group_by: {e}","messagePattern":"Table\\.group_by: (.+?)","errorType":"exception","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":1202,"sourceCode":"                        None => unimplemented!(\"group_by with non-string key_name\"),\n                    },\n                    None => \"group\",\n                };\n                let key_type = match key_type {\n                    Some(ty) => match ty.downcast_object_ref::<crate::DataType>() {\n                        Some(dt) => Some(dt.clone()),\n                        None => {\n                            // TODO: support DataType class instances\n                            unimplemented!(\"group_by with non-string key_type\")\n                        }\n                    },\n                    None => None,\n                };\n                let table_set = self\n                    .as_ref()\n                    .group_by_key(key, key_name, key_type)\n                    .map_err(|e| {\n                        Error::new(ErrorKind::InvalidOperation, format!(\"Table.group_by: {e}\"))\n                    })?;\n                Ok(Value::from_object(table_set))\n            }\n            // ```python\n            // def join(self, right_table, left_key=None, right_key=None, inner=False,\n            //         full_outer=False, require_match=False, columns=None):\n            //     \"\"\"\n            //     Create a new table by joining two table's on common values. This method\n            //     implements most varieties of SQL join, in addition to some unique features.\n            //\n            //     If :code:`left_key` and :code:`right_key` are both :code:`None` then this\n            //     method will perform a \"sequential join\", which is to say it will join on row\n            //     number. The :code:`inner` and :code:`full_outer` arguments will determine\n            //     whether dangling left-hand and right-hand rows are included, respectively.\n            //\n            //     If :code:`left_key` is specified, then a \"left outer join\" will be\n            //     performed. This will combine columns from the :code:`right_table` anywhere\n            //     that :code:`left_key` and :code:`right_key` are equal. Unmatched rows from","sourceCodeStart":1184,"sourceCodeEnd":1220,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L1184-L1220","documentation":"Thrown by `Table.group_by()` when the underlying `group_by_key` operation fails, wrapping the inner error as an InvalidOperation error with the prefix `Table.group_by:`. Grouping requires a valid key column with a consistent type; failures typically come from a missing key column, an unsupported key type, or an internal grouping error.","triggerScenarios":"Calling `table.group_by(key)` where `group_by_key` returns an error — e.g. the key column does not exist, the key type is unsupported for grouping, or key_name/key_type resolution fails.","commonSituations":"Grouping by a column name with a typo, grouping on a column removed by an earlier select, or grouping on a column whose dtype the group implementation does not support.","solutions":["Read the wrapped inner message after `Table.group_by:` for the root cause","Verify the key column exists in the table (`key in table.column_names`)","Check the key column's dtype is supported for grouping","Select/normalize the column before grouping if its type is unusual"],"exampleFix":"// before\nresults = table.group_by('catgory')  # typo\n// after\nassert 'category' in table.column_names\nresults = table.group_by('category')","handlingStrategy":"validation","validationCode":"def ensure_group_key(table, key):\n    if key not in table.column_names:\n        raise ValueError(f'group key {key!r} not in {table.column_names}')","typeGuard":"null","tryCatchPattern":"try:\n    grouped = table.group_by(key)\nexcept Exception as e:\n    if str(e).startswith('Table.group_by:'):\n        raise ValueError(f'cannot group by {key!r}: {e}') from e\n    raise","preventionTips":["Check the key column exists before grouping","Group only on columns with supported dtypes","Guard against columns dropped by earlier select chains"],"tags":["rust","data-table","grouping"],"backgroundTag":"database-query-failed","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"}