dbt-labs/dbt-core · error
cast() method not implemented for the
Error message
cast() method not implemented for the {} data type What it means
This DataTypeRepr implementation leaves cast() unimplemented, so any cast attempt — directly or via test(), which just wraps cast().is_ok() — fails for this data type. It marks type coercions the agate port has not yet provided.
Solutions
- Implement cast for this data type, or route the coercion through the string representation as a fallback
- Return a distinguishable Err so callers can treat it as 'cannot cast' rather than a crash
- Register a text-mediated fallback cast for unimplemented types
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/dbt-agate/src/data_type.rs:69 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/17527e6482a66699.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-agate/src/data_type.rs:69
pub trait DataTypeRepr: fmt::Debug + Send + Sync {
/// A sequence of values which should be cast to [None] when encountered by this data type.
fn null_values(&self) -> &NullValues<'static>;
/// The name of the [DataType] implementation.
fn type_name(&self) -> &str;
/// Test, for purposes of type inference, if a value could possibly be
/// coerced to this data type.
///
/// This is really just a thin wrapper around :meth:`DataType.cast`.
fn test(&self, d: &dyn DataTypeRepr) -> bool {
self.cast(d).is_ok()
}
/// Coerce a given string value into this column's data type.
fn cast(&self, d: &dyn DataTypeRepr) -> Result<Value, Error> {
// raise NotImplementedError
let err = Error::new(
ErrorKind::InvalidOperation,
format!(
"cast() method not implemented for the {} data type",
d.type_name()
),
);
Err(err)
}
/// Format a given native value for CSV serialization.
fn csvify(&self, d: &Value) -> Value {
if d.is_none() || d.is_undefined() {
Value::from(())
} else {
Value::from(d.to_string())
}
}
View on GitHub (pinned to 0267ce9170)