{"record":{"id":"d44060560722afc7","repo":"dbt-labs/dbt-core","slug":"table-distinct-e","errorCode":null,"errorMessage":"Table.distinct: {e}","messagePattern":"Table\\.distinct: (.+?)","errorType":"exception","errorClass":"InvalidOperation","httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":1387,"sourceCode":"                            Some(vec![s.to_string()])\n                        } else if let Ok(iter) = v.try_iter() {\n                            let mut keys = Vec::new();\n                            for key in iter {\n                                match key.as_str() {\n                                    Some(s) => keys.push(s.to_string()),\n                                    None => unimplemented!(\"distinct with non-string keys\"),\n                                }\n                            }\n                            Some(keys)\n                        } else {\n                            None\n                        }\n                    }\n                    None => None,\n                };\n\n                let result = self.as_ref().distinct(key).map_err(|e| {\n                    Error::new(ErrorKind::InvalidOperation, format!(\"Table.distinct: {e}\"))\n                })?;\n                Ok(Value::from_object(result))\n            }\n            other => unimplemented!(\"AgateTable::{}\", other),\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use crate::flat_record_batch::FlatRecordBatch;\n    use crate::test_fixtures::*;\n    use crate::*;\n    use arrow::array::{\n        ArrayRef, BooleanBuilder, DictionaryArray, Float64Builder, Int32Array, Int32Builder,\n        ListBuilder, StringBuilder, StringViewBuilder, StructBuilder,\n    };\n    use arrow::array::{GenericListArray, StringArray};","sourceCodeStart":1369,"sourceCodeEnd":1405,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L1369-L1405","documentation":"Thrown by the `Table.distinct()` method binding when the underlying `distinct(key)` operation fails, wrapping the inner error as an InvalidOperation error prefixed with `Table.distinct:`. Distinct requires an optional key that resolves to valid column(s); failures come from the internal deduplication step, e.g. an unknown key column.","triggerScenarios":"Calling `table.distinct(key)` where the internal `distinct` returns an error — typically `key` names a column that does not exist or a key of unsupported form, or the dedup row-index computation fails.","commonSituations":"Misspelled column name in the distinct key; column dropped by a prior select/limit chain; ported code passing a column index instead of a name.","solutions":["Read the wrapped inner message after `Table.distinct:` for the root cause","Verify the key column exists: `key in table.column_names`","Call `distinct()` with no argument to dedupe on all columns","Use a string column name (or list of names) for the key"],"exampleFix":"// before\ntable.distinct('catgory')  # typo\n// after\nassert 'category' in table.column_names\ntable.distinct('category')","handlingStrategy":"validation","validationCode":"if key is not None and key not in table.column_names:\n    raise ValueError(f'distinct key {key!r} not in {table.column_names}')","typeGuard":"null","tryCatchPattern":"try:\n    result = table.distinct(key)\nexcept Exception as e:\n    if str(e).startswith('Table.distinct:'):\n        raise ValueError(f'cannot compute distinct on {key!r}: {e}') from e\n    raise","preventionTips":["Verify key column names against table.column_names","Call distinct() with no key to dedupe on all columns","Use string column names, not indices"],"tags":["rust","data-table","argument-validation"],"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"}