{"record":{"id":"231c29f919c59058","repo":"dbt-labs/dbt-core","slug":"current-relation-should-not-be-none","errorCode":null,"errorMessage":"current_relation should not be None","messagePattern":"current_relation should not be None","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/metadata/snowflake/mod.rs","lineNumber":2077,"sourceCode":"        information_schema_result.column_values::<Decimal128Array>(\"NUMERIC_SCALE\")?;\n    let comments = information_schema_result.column_values::<StringArray>(\"COMMENT\")?;\n\n    let mut result = Vec::<(String, AdapterResult<RelationSchemaPair>)>::new();\n    let mut current_table = String::new();\n    let mut current_fields = Vec::new();\n    let mut current_relation: Option<Arc<dyn BaseRelation>> = None;\n\n    for i in 0..information_schema_result.num_rows() {\n        let catalog = table_catalogs.value(i);\n        let schema = table_schemas.value(i);\n        let table = table_names.value(i);\n        let fully_qualified_name = format!(\"{catalog}.{schema}.{table}\");\n\n        // If we're starting a new table, save the previous one and start fresh\n        if fully_qualified_name != current_table {\n            if !current_table.is_empty() {\n                let relation_schema: RelationSchemaPair = (\n                    current_relation.expect(\"current_relation should not be None\"),\n                    Arc::new(Schema::new(current_fields.clone())),\n                );\n                result.push((current_table.clone(), Ok(relation_schema)));\n            }\n            current_table = fully_qualified_name;\n            current_fields = Vec::new();\n\n            let relation = match crate::relation::do_create_relation(\n                type_ops.adapter_type(),\n                catalog.to_string(),\n                schema.to_string(),\n                Some(table.to_string()),\n                None,\n                quoting,\n            ) {\n                Ok(relation) => relation,\n                Err(e) => {\n                    result.push((current_table, Err(e.into())));","sourceCodeStart":2059,"sourceCodeEnd":2095,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/metadata/snowflake/mod.rs#L2059-L2095","documentation":"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.","triggerScenarios":"Thrown at crates/dbt-adapter/src/metadata/snowflake/mod.rs:2077 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}