{"record":{"id":"294e301357a7ab8d","repo":"dbt-labs/dbt-core","slug":"column-distinct","errorCode":null,"errorMessage":"column_distinct","messagePattern":"column_distinct","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":225,"sourceCode":"        let flat = self.flat.select(indices);\n        // row names remain the same when selecting columns\n        let row_names = self.row_names.as_ref().map(Arc::clone);\n        let repr = TableRepr::new(flat, None, row_names);\n        Arc::new(repr)\n    }\n\n    pub fn single_column_table(&self, idx: isize) -> Option<Arc<TableRepr>> {\n        let idx = self.adjusted_column_index(idx)?;\n        let flat_with_single_column = self.flat.with_single_column(idx);\n        let row_names = self.row_names.as_ref().map(Arc::clone);\n        let repr = TableRepr::new(flat_with_single_column, None, row_names);\n        Some(Arc::new(repr))\n    }\n\n    /// Return a single-column table with the distinct values in this column.\n    pub fn column_distinct(&self, col_idx: isize) -> Arc<Self> {\n        let _col = self.single_column_table(col_idx).unwrap();\n        todo!(\"column_distinct\")\n    }\n\n    pub fn column_without_nulls(&self, col_idx: isize) -> Arc<Self> {\n        let _col = self.single_column_table(col_idx).unwrap();\n        todo!(\"column_without_nulls\")\n    }\n\n    pub fn column_sorted(&self, col_idx: isize) -> Arc<Self> {\n        let _col = self.single_column_table(col_idx).unwrap();\n        todo!(\"column_sorted\")\n    }\n\n    pub fn column_without_nulls_sorted(&self, col_idx: isize) -> Arc<Self> {\n        let _col = self.single_column_table(col_idx).unwrap();\n        todo!(\"column_without_nulls_sorted\")\n    }\n\n    pub fn count_occurrences_of_value_in_column(&self, _needle: &Value, col_idx: isize) -> usize {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L207-L243","documentation":"`Table::column_distinct` in dbt-agate is an unimplemented public API: it computes the single-column subtable via `single_column_table` and then panics with `todo!(\"column_distinct\")`. The method is supposed to return a single-column table containing the distinct values of the given column (mirroring agate's `Table.distinct` on one column), but the deduplication logic is not yet written.","triggerScenarios":"Calling `table.column_distinct(col_idx)` with any column index on any table; the panic occurs after `single_column_table` succeeds, including for valid indices.","commonSituations":"Porting agate Python workflows that compute distinct column values (e.g., deduplicated domain lists for macros/tests); building summaries like unique dimension members in dbt-adjacent tooling.","solutions":["Compute distinct values manually: extract the column, iterate its values, deduplicate (e.g., with a HashSet or ordered set), and build a new single-column table yourself.","Use any existing alternative such as `column_without_nulls` equivalents or grouping APIs if implemented.","Implement the method upstream: take the single-column table, dedupe rows by value preserving first-seen order, and return the resulting table."],"exampleFix":"// before (crates/dbt-agate/src/table.rs)\npub fn column_distinct(&self, col_idx: isize) -> Arc<Self> {\n    let _col = self.single_column_table(col_idx).unwrap();\n    todo!(\"column_distinct\")\n}\n// after\npub fn column_distinct(&self, col_idx: isize) -> Arc<Self> {\n    let col = self.single_column_table(col_idx).unwrap();\n    let mut seen = IndexSet::new();\n    for v in col.column_values(0) { seen.insert(v.clone()); }\n    self.from_columns_rows(/* distinct rows built from `seen` */)\n}","handlingStrategy":"validation","validationCode":"// check the API surface is implemented before relying on it (or just compute distinct yourself):\nlet distinct: Vec<Value> = {\n    let col = table.single_column_table(col_idx).unwrap();\n    let mut seen = std::collections::HashSet::new();\n    let mut out = Vec::new();\n    for v in col.column_values(0) {\n        if seen.insert(v.clone()) { out.push(v.clone()); }\n    }\n    out\n};","typeGuard":null,"tryCatchPattern":"// isolate the panicking call if you must probe:\nlet result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| table.column_distinct(idx)));\n// treat Err as \"not implemented\" and fall back to manual dedup","preventionTips":["Compute distinct column values with your own dedup loop until the method is implemented.","Review dbt-agate source for todo!() placeholders before adopting public methods in new code.","Add a test that exercises each table API you use so unimplemented paths surface in CI, not production."],"tags":["unimplemented","agate","rust-panic","table-operations"],"backgroundTag":"method-not-implemented","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"}