dbt-labs/dbt-core · error
disambiguate_column_names: schema and columns should be…
Error message
disambiguate_column_names: schema and columns should be compatible
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/dbt-adapter/src/record_batch.rs:178 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/04d69f02963dacd1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-adapter/src/record_batch.rs:178
}
if let Some(callback) = on_disambiguate {
callback(&renamed_columns);
}
let new_fields: Vec<_> = fields
.iter()
.zip(new_names.iter())
.map(|(field, new_name)| Arc::new(field.as_ref().clone().with_name(new_name.clone())))
.collect();
let new_schema = Arc::new(Schema::new_with_metadata(
new_fields,
schema.metadata().clone(),
));
RecordBatch::try_new(new_schema, self.columns().to_vec())
.expect("disambiguate_column_names: schema and columns should be compatible")
}
/// Stringify nested columns, ignoring struct fields
///
/// dbt Core flattens struct fields as JSON strings for certain adapters, only keeping the
/// root-level columns.
///
/// Reference: https://github.com/dbt-labs/dbt-common/blob/f21aa0d3093e98c7c35ed93163832c84f46eb3d8/dbt_common/clients/agate_helper.py#L110
fn jsonify_nested_columns(self) -> RecordBatch {
let schema = self.schema();
let fields = schema.fields();
if !fields.iter().any(|f| f.data_type().is_nested()) {
return self;
}
let options = EncoderOptions::default();
let mut new_fields: Vec<Arc<Field>> = Vec::with_capacity(fields.len());View on GitHub (pinned to 0267ce9170)