dbt-labs/dbt-core · error
adapter should be configured for the parse phase
Error message
adapter should be configured for the parse phase
What it means
During parse-phase Jinja method dispatch (`call_method` for `get_columns_in_relation`), the code retrieves the parse-phase adapter state via `parse_adapter_state()` and panics if it is None. The state is installed when the parse adapter is constructed, so a None here means the method was invoked outside the parse phase or before the adapter state was configured.
Solutions
- Ensure the adapter is constructed/registered with its parse state during the parse phase
- Update adapter and parser crates to matching versions
- Move/refrain from calling `get_columns_in_relation` outside parse-phase evaluation
- Replace the expect with a proper error reporting the missing phase state
Example fix
// before
self.parse_adapter.parse_adapter_state().expect("adapter should be configured for the parse phase")
// after
let state = self.parse_adapter.parse_adapter_state()
.ok_or_else(|| format_err!("get_columns_in_relation called outside parse phase"))?; Defensive patterns
Strategy: validation
Validate before calling
// guard before calling phase-specific jinja methods
if adapter.parse_adapter_state().is_none() {
return Err("get_columns_in_relation requires parse-phase adapter state".into());
} Try / catch
let Some(state) = self.parse_adapter.parse_adapter_state() else {
return Err(format_err!("adapter not in parse phase"));
}; Prevention
- Register parse adapter state during parse-phase construction
- Keep dbt-parser and adapter crate versions aligned
- Avoid invoking get_columns_in_relation outside parse-phase evaluation
When it happens
Trigger: A dbt template calls `get_columns_in_relation` while the adapter is not in parse phase (e.g. during runtime/execute phase, or an adapter variant whose `parse_adapter_state` was never set before `call_method` runs).
Common situations: Custom adapters not wiring up `parse_adapter_state` in their parse-phase construction; macros invoking `get_columns_in_relation` at the wrong phase; version skew between dbt-parser and adapter crates changing the state setup contract.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Adapter must be configured for the parse phase
- Adapter should be available during parse phase
- adapter not found in context
- agate_table
- Athena
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/d14e1844ba99edf5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-parser/src/dbt_namespace.rs:60
name: &str,
args: &[MinijinjaValue],
listeners: &[Rc<dyn RenderingEventListener>],
) -> Result<MinijinjaValue, MinijinjaError> {
// Intercept specific method calls to track them
match name {
"get_columns_in_relation" => {
// Track the call in the parse adapter
// Extract relation from args
let relation = args.first().ok_or_else(|| {
MinijinjaError::new(
MinijinjaErrorKind::InvalidOperation,
"get_columns_in_relation requires one argument",
)
})?;
let relation = downcast_value_to_dyn_base_relation(relation)?;
self.parse_adapter
.parse_adapter_state()
.expect("adapter should be configured for the parse phase")
.record_get_columns_in_relation_call(state, relation.as_ref())?;
// Delegate to the original dbt.get_columns_in_relation template
let template_name = "dbt.get_columns_in_relation";
if let Ok(template) = state.env().get_template(template_name) {
let base_ctx = state.get_base_context();
let template_state = template.eval_to_state(base_ctx, listeners)?;
let func = template_state
.lookup("get_columns_in_relation", listeners)
.ok_or_else(|| {
MinijinjaError::new(
MinijinjaErrorKind::InvalidOperation,
"get_columns_in_relation macro not found",
)
})?;
func.call(&template_state, args, listeners)
} else {
Err(MinijinjaError::new(View on GitHub (pinned to 0267ce9170)