{"record":{"id":"2747bad829768275","repo":"dbt-labs/dbt-core","slug":"not-all-tables-have-the-same-column-types","errorCode":null,"errorMessage":"Not all tables have the same column types!","messagePattern":"Not all tables have the same column types!","errorType":"validation","errorClass":"InvalidArgument","httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table_set.rs","lineNumber":142,"sourceCode":"        keys: Vec<Value>,\n        key_name: Option<String>,\n        key_type: Option<crate::DataType>,\n        is_fork: bool,\n    ) -> Result<Arc<Self>, Error> {\n        let key_name = key_name.unwrap_or_else(|| \"group\".to_string());\n        let key_type = key_type.unwrap_or_else(|| crate::DataType::new(\"Text\".to_string()));\n        let sample_table = tables.first().map(Arc::clone);\n\n        let column_types = sample_table.as_ref().map(|t| t.column_types_as_tuple());\n        let column_names = sample_table.as_ref().map(|t| t.column_names_as_tuple());\n\n        if !is_fork {\n            for table in &tables {\n                let self_column_types = column_types\n                    .as_ref()\n                    .expect(\"column types from sample table\");\n                if table.column_types_as_tuple() != *self_column_types {\n                    return Err(Error::new(\n                        ErrorKind::InvalidArgument,\n                        \"Not all tables have the same column types!\",\n                    ));\n                }\n\n                let self_column_names = column_names\n                    .as_ref()\n                    .expect(\"column names from sample table\");\n                if table.column_names_as_tuple() != *self_column_names {\n                    return Err(Error::new(\n                        ErrorKind::InvalidArgument,\n                        \"Not all tables have the same column names!\",\n                    ));\n                }\n            }\n        }\n\n        let repr = TableSetRepr {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table_set.rs#L124-L160","documentation":"Thrown when constructing a `TableSet` (`try_new`) from multiple tables whose column types differ. By default (unless fork/merge behavior is enabled via `is_fork`), a TableSet requires all member tables to share identical column types, validated against the sample table. This keeps grouping/merging across the set well-defined.","triggerScenarios":"Calling `TableSet::try_new` (Python `agate.TableSet`) with tables where at least one table's column types tuple differs from the others — e.g. a column inferred as Number in one table and Text in another.","commonSituations":"Combining CSVs where one file has an empty cell forcing a Text column; tables built from different queries with drifted schemas; a version change altering type inference for one input.","solutions":["Align schemas so all tables share the same column types (cast columns explicitly, e.g. cast all to Text)","Use `column_types` arguments when creating the source tables to force consistent types","If intentional divergence is desired, use the fork behavior (`is_fork` path) that skips validation","Normalize the data before building the TableSet (fill nulls, standardize formats)"],"exampleFix":"// before\nTableSet(tables)  # column 'amount' is Number in one table, Text in another\n// after\ntables = [t.cast_column('amount', agate.Number()) for t in raw_tables]\nTableSet(tables)","handlingStrategy":"validation","validationCode":"types = [t.column_types_as_tuple() for t in tables]\nif any(ty != types[0] for ty in types[1:]):\n    raise ValueError('tables must share identical column types')","typeGuard":"null","tryCatchPattern":"try:\n    ts = agate.TableSet(tables, key_name='group')\nexcept Exception as e:\n    if 'same column types' in str(e):\n        tables = [align_column_types(t, types[0]) for t in tables]\n        ts = agate.TableSet(tables, key_name='group')\n    else:\n        raise","preventionTips":["Force column_types when loading source tables","Cast divergent columns to a common type before set construction","Standardize CSV/query schemas across all inputs"],"tags":["rust","schema","data-table"],"backgroundTag":"schema-validation-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"}