Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a slight rework of 955 to keep a seperation of concerns #957

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions dbt/adapters/bigquery/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,18 @@ def get_table_from_response(cls, resp):
column_names = [field.name for field in resp.schema]
return agate_helper.table_from_data_flat(resp, column_names)

def get_labels_from_query_comment(cls):
if (
hasattr(cls.profile, "query_comment")
and cls.profile.query_comment
and cls.profile.query_comment.job_label
and cls.query_header
):
query_comment = cls.query_header.comment.query_comment
return cls._labels_from_query_comment(query_comment)

return {}

def raw_execute(
self,
sql,
Expand All @@ -447,16 +459,7 @@ def raw_execute(

fire_event(SQLQuery(conn_name=conn.name, sql=sql, node_info=get_node_info()))

if (
hasattr(self.profile, "query_comment")
and self.profile.query_comment
and self.profile.query_comment.job_label
and self.query_header
and (query_comment := self.query_header.comment.query_comment)
):
labels = self._labels_from_query_comment(query_comment)
else:
labels = {}
labels = self.get_labels_from_query_comment()

if active_user:
labels["dbt_invocation_id"] = active_user.invocation_id
Expand Down