dbt-labs/dbt-core · error
current_relation should not be None
Error message
current_relation should not be None
What it means
Invariant expect inside build_schemas_from_information_schema: while iterating information-schema rows grouped per relation, the loop hit a row for a new/current relation but current_relation was still None, meaning the grouping state machine saw column rows before any relation row. Fires only on malformed or unexpected information_schema result ordering/content.
Solutions
- Check the information_schema query results for missing or reordered table-identifier rows
- Report as an internal bug with the Snowflake information_schema payload attached
- Verify the row-grouping logic initializes current_relation before consuming column rows
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/dbt-adapter/src/metadata/snowflake/mod.rs:2077 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/231c29f919c59058.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-adapter/src/metadata/snowflake/mod.rs:2077
information_schema_result.column_values::<Decimal128Array>("NUMERIC_SCALE")?;
let comments = information_schema_result.column_values::<StringArray>("COMMENT")?;
let mut result = Vec::<(String, AdapterResult<RelationSchemaPair>)>::new();
let mut current_table = String::new();
let mut current_fields = Vec::new();
let mut current_relation: Option<Arc<dyn BaseRelation>> = None;
for i in 0..information_schema_result.num_rows() {
let catalog = table_catalogs.value(i);
let schema = table_schemas.value(i);
let table = table_names.value(i);
let fully_qualified_name = format!("{catalog}.{schema}.{table}");
// If we're starting a new table, save the previous one and start fresh
if fully_qualified_name != current_table {
if !current_table.is_empty() {
let relation_schema: RelationSchemaPair = (
current_relation.expect("current_relation should not be None"),
Arc::new(Schema::new(current_fields.clone())),
);
result.push((current_table.clone(), Ok(relation_schema)));
}
current_table = fully_qualified_name;
current_fields = Vec::new();
let relation = match crate::relation::do_create_relation(
type_ops.adapter_type(),
catalog.to_string(),
schema.to_string(),
Some(table.to_string()),
None,
quoting,
) {
Ok(relation) => relation,
Err(e) => {
result.push((current_table, Err(e.into())));View on GitHub (pinned to 0267ce9170)