dbt-labs/dbt-core · error
type conversion from table column in MockAdapter
Error message
type conversion from table column in MockAdapter
What it means
AdapterImpl::convert_type panics when called on a MockAdapter. This method maps an Arrow field DataType from an AgateTable column into the adapter's SQL type string; the mock adapter has no meaningful type-mapping to offer, so the case is explicitly unimplemented.
Source
Thrown at crates/dbt-adapter/src/adapter/adapter_impl.rs:2357
) => {
if quote_config.unwrap_or(true) {
Ok(self.quote(column))
} else {
Ok(column.to_string())
}
}
}
}
/// BaseAdapter https://github.com/dbt-labs/dbt-adapters/blob/0efd8d3d1081e1ab43e38797d5104f7b424a6284/dbt-adapters/src/dbt/adapters/base/impl.py#L1231
pub fn convert_type(
&self,
state: &State,
table: Arc<AgateTable>,
col_idx: i64,
) -> AdapterResult<String> {
if self.mock_state().is_some() {
unimplemented!("type conversion from table column in MockAdapter")
}
let batch = table.original_record_batch();
let schema = batch.schema();
let data_type = schema.field(col_idx as usize).data_type();
let data_type = match data_type {
dt if dt.is_null() => &DataType::Int32,
DataType::Float64 => {
let is_int = batch
.column(col_idx as usize)
.as_any()
.downcast_ref::<arrow_array::Float64Array>()
.is_some_and(try_to_int_col);
if is_int { &DataType::Int64 } else { data_type }
}
dt => dt,
};
View on GitHub (pinned to 0267ce9170)
Solutions
- Use a real adapter when type conversion of table columns is needed.
- Avoid code paths that render column DDL/types from AgateTables in mock mode.
- Extend the mock branch in convert_type to return a generic type (e.g. from the Arrow schema) instead of panicking.
Example fix
// before
if self.mock_state().is_some() {
unimplemented!("type conversion from table column in MockAdapter")
}
// after
if self.mock_state().is_some() {
return Ok(default_type_for(data_type));
} Defensive patterns
Strategy: validation
Validate before calling
if adapter.is_mock() {
return Err("convert_type requires a real adapter".into());
} Type guard
fn supports_type_conversion(adapter: &AdapterImpl) -> bool { adapter.mock_state().is_none() } Prevention
- Do not render column DDL/types from AgateTables under a mock adapter
- Use a real adapter for seeds or any flow that needs column type mapping
- Keep mock-mode tests limited to parsing-level assertions
When it happens
Trigger: Calling convert_type(state, table, col_idx) on an adapter in mock mode — typically during column schema rendering of loaded AgateTables under parse/mock runs.
Common situations: Seed or model column rendering pipelines running with a mock adapter; tests that load table data into AgateTable but never execute against a real adapter.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- query addition to connection in MockAdapter
- load_dataframe() for the Salesforce adapter
- Starburst
- Athena
- Trino
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/ed5e86c0a2a43c3a.
Report an issue: GitHub.