{"record":{"id":"04d69f02963dacd1","repo":"dbt-labs/dbt-core","slug":"disambiguate-column-names-schema-and-columns-shou","errorCode":null,"errorMessage":"disambiguate_column_names: schema and columns should be compatible","messagePattern":"disambiguate_column_names: schema and columns should be compatible","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/record_batch.rs","lineNumber":178,"sourceCode":"        }\n\n        if let Some(callback) = on_disambiguate {\n            callback(&renamed_columns);\n        }\n\n        let new_fields: Vec<_> = fields\n            .iter()\n            .zip(new_names.iter())\n            .map(|(field, new_name)| Arc::new(field.as_ref().clone().with_name(new_name.clone())))\n            .collect();\n\n        let new_schema = Arc::new(Schema::new_with_metadata(\n            new_fields,\n            schema.metadata().clone(),\n        ));\n\n        RecordBatch::try_new(new_schema, self.columns().to_vec())\n            .expect(\"disambiguate_column_names: schema and columns should be compatible\")\n    }\n\n    /// Stringify nested columns, ignoring struct fields\n    ///\n    /// dbt Core flattens struct fields as JSON strings for certain adapters, only keeping the\n    /// root-level columns.\n    ///\n    /// Reference: https://github.com/dbt-labs/dbt-common/blob/f21aa0d3093e98c7c35ed93163832c84f46eb3d8/dbt_common/clients/agate_helper.py#L110\n    fn jsonify_nested_columns(self) -> RecordBatch {\n        let schema = self.schema();\n        let fields = schema.fields();\n\n        if !fields.iter().any(|f| f.data_type().is_nested()) {\n            return self;\n        }\n\n        let options = EncoderOptions::default();\n        let mut new_fields: Vec<Arc<Field>> = Vec::with_capacity(fields.len());","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/record_batch.rs#L160-L196","documentation":"Invariant expect at the end of disambiguate_column_names: rebuilding the RecordBatch with renamed fields via RecordBatch::try_new failed, which should be impossible because only field names changed. It fires only if the new field list is somehow out of sync with the existing columns (an internal logic bug), not due to user input.","triggerScenarios":"Thrown at crates/dbt-adapter/src/record_batch.rs:178 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the renamed field list for length/type mismatch with the original columns","Report as an internal bug in disambiguate_column_names","Add a regression test covering the schema that triggered the mismatch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}