{"record":{"id":"a48fa3fa30a4a2bf","repo":"dbt-labs/dbt-core","slug":"flatten-is-only-implemented-for-bigquery","errorCode":null,"errorMessage":"'flatten' is only implemented for Bigquery","messagePattern":"'flatten' is only implemented for Bigquery","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-adapter/src/column/types.rs","lineNumber":1148,"sourceCode":"                new_prefix,\n                original_sql_str,\n                &[],\n                self.mode(),\n            )])\n        } else {\n            let mut new_fields = Vec::new();\n            for f in &self._fields {\n                let mut flatten_f = f._bq_flatten_inner(&new_prefix);\n                new_fields.append(&mut flatten_f);\n            }\n            new_fields\n        }\n    }\n\n    /// https://github.com/dbt-labs/dbt-adapters/blob/c16cc7047e8678f8bb88ae294f43da2c68e9f5cc/dbt-bigquery/src/dbt/adapters/bigquery/column.py#L69\n    pub fn flatten(&self) -> Vec<Self> {\n        if !matches!(self._adapter_type, AdapterType::Bigquery) {\n            unimplemented!(\"'flatten' is only implemented for Bigquery\")\n        }\n\n        self._bq_flatten_inner(\"\")\n    }\n\n    pub fn fields(&self) -> &[Self] {\n        &self._fields\n    }\n}\n\nimpl Object for Column {\n    fn call_method(\n        self: &Arc<Self>,\n        _state: &minijinja::State,\n        name: &str,\n        args: &[Value],\n        _listeners: &[std::rc::Rc<dyn minijinja::listener::RenderingEventListener>],\n    ) -> Result<Value, minijinja::Error> {","sourceCodeStart":1130,"sourceCodeEnd":1166,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-adapter/src/column/types.rs#L1130-L1166","documentation":"flatten() expands a nested (RECORD/STRUCT) BigQuery column into a flat list of leaf columns, mirroring dbt-bigquery's BigQueryColumn.flatten(). Because nested-column flattening only exists for BigQuery's type system, the method panics with unimplemented!() for every other adapter type before delegating to _bq_flatten_inner.","triggerScenarios":"Calling DbtColumn::flatten() on a column whose _adapter_type is not AdapterType::Bigquery — typically from a Jinja macro doing flatten_column or nested field traversal on another warehouse.","commonSituations":"Copying dbt-bigquery macros that flatten STRUCT columns into a Snowflake/Redshift/Databricks project; processing columns loaded from a non-BigQuery relation with a BigQuery-specific code path; unit tests using default (non-BigQuery) adapter type.","solutions":["Guard the call on adapter type: {% if adapter.type() == 'bigquery' %} before flattening.","For other warehouses, iterate the column list directly or handle nested types with platform-native mechanisms (e.g. Snowflake VARIANT / Redshift SUPER accessors).","If BigQuery flattening is intended, ensure columns were constructed with the BigQuery adapter type set (AdapterType::Bigquery)."],"exampleFix":"// before\nlet flat = column.flatten();\n\n// after\nlet flat = if matches!(column.adapter_type(), AdapterType::Bigquery) {\n    column.flatten()\n} else {\n    vec![column.clone()]\n};","handlingStrategy":"validation","validationCode":"if adapter_type != AdapterType::Bigquery { /* do not flatten; handle nested types per platform */ }","typeGuard":"fn is_bigquery(t: &AdapterType) -> bool { *t == AdapterType::Bigquery }","tryCatchPattern":null,"preventionTips":["Only flatten STRUCT/RECORD columns on BigQuery relations.","Handle nested types with warehouse-native mechanisms on other platforms.","Annotate BigQuery-specific helpers clearly so they aren't reused generically."],"tags":["unimplemented","adapter-compat","bigquery","nested-columns"],"backgroundTag":"method-not-implemented","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"}