3939import dbt_common .exceptions
4040import dbt_common .exceptions .base
4141from dbt_common .exceptions import DbtInternalError
42- from dbt_common .record import record_function
42+ from dbt_common .record import auto_record_function , record_function
4343from dbt_common .utils import filter_null_values
4444from dbt .adapters .base import (
4545 AdapterConfig ,
8080from dbt .adapters .bigquery .record .record_types import (
8181 BigQueryAdapterDescribeRelationRecord ,
8282 BigQueryAdapterIsReplaceableRecord ,
83+ BigQueryAdapterCopyTableRecord ,
84+ BigQueryAdapterGetDatasetLocationRecord ,
85+ BigQueryAdapterGrantAccessToRecord ,
86+ BigQueryAdapterGetColumnsInSelectSqlRecord ,
87+ BigQueryAdapterAlterTableAddColumnsRecord ,
88+ BigQueryAdapterUpdateColumnsRecord ,
89+ BigQueryAdapterLoadDataframeRecord ,
90+ BigQueryAdapterAlterTableAddRemoveColumnsRecord ,
91+ BigQueryAdapterSyncStructColumnsRecord ,
8392)
8493from dbt .adapters .bigquery .relation import BigQueryRelation
8594from dbt .adapters .bigquery .relation_configs import (
@@ -553,6 +562,12 @@ def _agate_to_schema(
553562 return bq_schema
554563
555564 @available .parse (lambda * a , ** k : "" )
565+ @record_function (
566+ BigQueryAdapterCopyTableRecord ,
567+ method = True ,
568+ index_on_thread_id = True ,
569+ id_field_name = "thread_id" ,
570+ )
556571 def copy_table (self , source , destination , materialization ):
557572 if materialization == "incremental" :
558573 write_disposition = WRITE_APPEND
@@ -584,6 +599,12 @@ def get_column_schema_from_query(self, sql: str) -> List[BigQueryColumn]:
584599 return flattened_columns
585600
586601 @available .parse (lambda * a , ** k : False )
602+ @record_function (
603+ BigQueryAdapterGetColumnsInSelectSqlRecord ,
604+ method = True ,
605+ index_on_thread_id = True ,
606+ id_field_name = "thread_id" ,
607+ )
587608 def get_columns_in_select_sql (self , select_sql : str ) -> List [BigQueryColumn ]:
588609 try :
589610 conn = self .connections .get_thread_connection ()
@@ -770,6 +791,12 @@ def _update_column_dict(self, bq_column_dict, dbt_columns, parent=""):
770791 return bq_column_dict
771792
772793 @available .parse_none
794+ @record_function (
795+ BigQueryAdapterUpdateColumnsRecord ,
796+ method = True ,
797+ index_on_thread_id = True ,
798+ id_field_name = "thread_id" ,
799+ )
773800 def update_columns (self , relation , columns ):
774801 if len (columns ) == 0 :
775802 return
@@ -787,6 +814,7 @@ def update_columns(self, relation, columns):
787814 new_table = google .cloud .bigquery .Table (table_ref , schema = new_schema )
788815 conn .handle .update_table (new_table , ["schema" ])
789816
817+ @auto_record_function ("AdapterUpdateTableDescription" , group = "Available" )
790818 @available .parse_none
791819 def update_table_description (
792820 self , database : str , schema : str , identifier : str , description : str
@@ -800,11 +828,23 @@ def update_table_description(
800828 client .update_table (table , ["description" ])
801829
802830 @available .parse_none
831+ @record_function (
832+ BigQueryAdapterAlterTableAddColumnsRecord ,
833+ method = True ,
834+ index_on_thread_id = True ,
835+ id_field_name = "thread_id" ,
836+ )
803837 def alter_table_add_columns (self , relation , columns ):
804838 logger .debug ('Adding columns ({}) to table "{}".' .format (columns , relation ))
805839 self .alter_table_add_remove_columns (relation , columns , None )
806840
807841 @available .parse_none
842+ @record_function (
843+ BigQueryAdapterAlterTableAddRemoveColumnsRecord ,
844+ method = True ,
845+ index_on_thread_id = True ,
846+ id_field_name = "thread_id" ,
847+ )
808848 def alter_table_add_remove_columns (self , relation , add_columns , remove_columns ):
809849 conn = self .connections .get_thread_connection ()
810850 client = conn .handle
@@ -856,6 +896,12 @@ def alter_table_add_remove_columns(self, relation, add_columns, remove_columns):
856896 client .update_table (new_table , ["schema" ])
857897
858898 @available .parse (lambda * a , ** k : {})
899+ @record_function (
900+ BigQueryAdapterSyncStructColumnsRecord ,
901+ method = True ,
902+ index_on_thread_id = True ,
903+ id_field_name = "thread_id" ,
904+ )
859905 def sync_struct_columns (
860906 self ,
861907 on_schema_change : str ,
@@ -988,6 +1034,12 @@ def sync_struct_columns(
9881034 return schema_changes_dict
9891035
9901036 @available .parse_none
1037+ @record_function (
1038+ BigQueryAdapterLoadDataframeRecord ,
1039+ method = True ,
1040+ index_on_thread_id = True ,
1041+ id_field_name = "thread_id" ,
1042+ )
9911043 def load_dataframe (
9921044 self ,
9931045 database : str ,
@@ -1299,6 +1351,12 @@ def describe_relation(
12991351 return None
13001352
13011353 @available .parse_none
1354+ @record_function (
1355+ BigQueryAdapterGrantAccessToRecord ,
1356+ method = True ,
1357+ index_on_thread_id = True ,
1358+ id_field_name = "thread_id" ,
1359+ )
13021360 def grant_access_to (self , entity , entity_type , role , grant_target_dict ) -> None :
13031361 """
13041362 Given an entity, grants it access to a dataset.
@@ -1321,6 +1379,12 @@ def grant_access_to(self, entity, entity_type, role, grant_target_dict) -> None:
13211379 client .update_dataset (dataset , ["access_entries" ])
13221380
13231381 @available .parse_none
1382+ @record_function (
1383+ BigQueryAdapterGetDatasetLocationRecord ,
1384+ method = True ,
1385+ index_on_thread_id = True ,
1386+ id_field_name = "thread_id" ,
1387+ )
13241388 def get_dataset_location (self , relation ):
13251389 conn = self .connections .get_thread_connection ()
13261390 client = conn .handle
0 commit comments