{"record":{"id":"4a984c742f38df22","repo":"dbt-labs/dbt-core","slug":"table-distinct-error-selecting-rows-e","errorCode":null,"errorMessage":"Table.distinct: error selecting rows: {e}","messagePattern":"Table\\.distinct: error selecting rows: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table.rs","lineNumber":976,"sourceCode":"        let mut seen_groups = HashSet::new();\n        let indices: Vec<u64> = grouper\n            .iter()\n            .enumerate()\n            .filter_map(|(row_idx, group_id)| {\n                if seen_groups.insert(group_id) {\n                    Some(row_idx as u64)\n                } else {\n                    None\n                }\n            })\n            .collect();\n        let selection_vector = UInt64Array::new(indices.into(), None);\n\n        let repr = self\n            .repr\n            .select_rows(&selection_vector, None)\n            .map_err(|e| {\n                Error::new(\n                    ErrorKind::InvalidOperation,\n                    format!(\"Table.distinct: error selecting rows: {e}\"),\n                )\n            })?;\n        Ok(AgateTable::from_repr(repr.into()))\n    }\n}\n\nimpl Default for AgateTable {\n    fn default() -> Self {\n        let batch = RecordBatch::new_empty(Arc::new(Schema::empty()));\n        Self::from_record_batch(Arc::new(batch))\n    }\n}\n\n// TODO(felipecrv): implement the AgateTable Python API\n// https://github.com/wireservice/agate/blob/master/agate/table/__init__.py#L34\nimpl Object for AgateTable {","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table.rs#L958-L994","documentation":"Thrown when `Table.distinct()` fails to select the distinct rows from the underlying Arrow table. The internal `select_rows` operation on the table's representation (which materializes the deduplicated row indices into a new table) returned an error, which is wrapped as an InvalidOperation error. This indicates the row-selection step of the distinct computation failed, typically due to an internal state or schema problem.","triggerScenarios":"Calling `table.distinct(key)` (Python `Table.distinct`) where the computed distinct row indices cannot be applied via `repr.select_rows`, e.g. due to an internal select_rows failure on the table representation.","commonSituations":"Running dbt-agate table pipelines that deduplicate rows; usually surfaces when the underlying table repr is corrupted or the select implementation encounters an unsupported schema, rather than from bad user input.","solutions":["Inspect the wrapped inner error message (`Table.distinct: error selecting rows: {e}`) for the root cause from select_rows","Verify the table's schema/columns are well-formed before calling distinct","Rebuild the table from source data if its repr may be stale or corrupted","If reproducible, file a bug with a minimal reproduction since this wraps an internal operation"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    distinct_table = table.distinct(key)\nexcept Exception as e:\n    if 'error selecting rows' in str(e):\n        # rebuild table or log internal failure\n        distinct_table = table\n    else:\n        raise","preventionTips":["Keep table schemas simple and well-typed before dedup","Rebuild tables from source instead of long-lived mutated tables","Report reproducible select_rows failures upstream"],"tags":["rust","data-table","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}