@@ -291,14 +291,36 @@ def list_relations_without_caching(self, schema_relation: BaseRelation) -> t.Lis
291291 return relations
292292
293293 def get_columns_in_relation (self , relation : BaseRelation ) -> t .List [Column ]:
294- from dbt .adapters .base .column import Column
295-
296294 mapped_table = self ._map_table_name (self ._normalize (self ._relation_to_table (relation )))
295+
296+ columns = self .engine_adapter .columns (table_name = mapped_table ).items ()
297+
298+ if self .project_dialect == "bigquery" :
299+ # dbt.adapters.bigquery.column.BigQueryColumn has a different constructor signature
300+ # We need to use BigQueryColumn.create_from_field() to create the column instead
301+ if (
302+ hasattr (self .column_type , "create_from_field" )
303+ and callable (getattr (self .column_type , "create_from_field" ))
304+ and hasattr (self .engine_adapter , "get_bq_schema" )
305+ and callable (getattr (self .engine_adapter , "get_bq_schema" ))
306+ ):
307+ return [
308+ self .column_type .create_from_field (field ) # type: ignore
309+ for field in self .engine_adapter .get_bq_schema (mapped_table ) # type: ignore
310+ ]
311+ from dbt .adapters .base .column import Column
312+
313+ return [
314+ Column .from_description (
315+ name = name , raw_data_type = dtype .sql (dialect = self .project_dialect )
316+ )
317+ for name , dtype in columns
318+ ]
297319 return [
298- Column .from_description (
320+ self . column_type .from_description (
299321 name = name , raw_data_type = dtype .sql (dialect = self .project_dialect )
300322 )
301- for name , dtype in self . engine_adapter . columns ( table_name = mapped_table ). items ()
323+ for name , dtype in columns
302324 ]
303325
304326 def get_missing_columns (
0 commit comments