{"record":{"id":"65e9e884cf5d28c7","repo":"dbt-labs/dbt-core","slug":"not-all-tables-have-the-same-column-names","errorCode":null,"errorMessage":"Not all tables have the same column names!","messagePattern":"Not all tables have the same column names!","errorType":"validation","errorClass":"InvalidArgument","httpStatus":null,"severity":"error","filePath":"crates/dbt-agate/src/table_set.rs","lineNumber":152,"sourceCode":"        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 {\n            key_name,\n            key_type,\n            sample_table,\n            column_types,\n            column_names,\n            tables,\n            keys,\n        };\n        Ok(Arc::new(repr))\n    }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-agate/src/table_set.rs#L134-L170","documentation":"Thrown when constructing a `TableSet` (`try_new`) from multiple tables whose column names differ. All tables in a TableSet must have identical column names (validated against the sample table) unless the fork path is taken; a name mismatch makes set-wide operations ambiguous, so this InvalidArgument error is raised.","triggerScenarios":"Calling `TableSet::try_new` with tables where at least one table's column names tuple differs from the others — reordered, renamed, missing, or extra columns.","commonSituations":"Combining CSVs from different periods where a column was renamed; tables from queries with SELECT column order changed; schema drift between sources.","solutions":["Rename columns so all tables match (`rename` / `rename_column` on the divergent tables)","Reorder/select columns to a common set before constructing the TableSet","Use the fork behavior (`is_fork` path) if differing schemas are intentional","Standardize the upstream queries/files so column names stay stable"],"exampleFix":"// before\nTableSet(tables)  # one table has 'region', others have 'area'\n// after\ntables = [t.rename_column('area', 'region') if 'area' in t.column_names else t for t in raw_tables]\nTableSet(tables)","handlingStrategy":"validation","validationCode":"names = [t.column_names_as_tuple() for t in tables]\nif any(n != names[0] for n in names[1:]):\n    raise ValueError('tables must share identical column names')","typeGuard":"null","tryCatchPattern":"try:\n    ts = agate.TableSet(tables, key_name='group')\nexcept Exception as e:\n    if 'same column names' in str(e):\n        tables = [align_column_names(t, names[0]) for t in tables]\n        ts = agate.TableSet(tables, key_name='group')\n    else:\n        raise","preventionTips":["Rename/reorder columns to a canonical schema before building a TableSet","Keep source queries' SELECT lists stable","Detect schema drift upstream and normalize early"],"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"}