mobuchowski commented on code in PR #31293:
URL: https://github.com/apache/airflow/pull/31293#discussion_r1200468846


##########
airflow/providers/google/cloud/operators/bigquery.py:
##########
@@ -1177,14 +1178,56 @@ def execute(self, context: Context):
             ]
         else:
             raise AirflowException(f"argument 'sql' of type {type(str)} is 
neither a string nor an iterable")
-        context["task_instance"].xcom_push(key="job_id", value=job_id)
+        context["task_instance"].xcom_push(key="job_id", value=self.job_id)
 
     def on_kill(self) -> None:
         super().on_kill()
         if self.hook is not None:
             self.log.info("Cancelling running query")
             self.hook.cancel_job(self.hook.running_job_id)
 
+    def get_openlineage_facets_on_complete(self, task_instance):
+        try:
+            from openlineage.client.facet import SqlJobFacet
+            from openlineage.common.provider.bigquery import 
BigQueryDatasetsProvider
+
+            from airflow.providers.openlineage.extractors import 
OperatorLineage
+            from airflow.providers.openlineage.utils.utils import normalize_sql
+        except ImportError:
+            return None
+
+        if not self.job_id:
+            return OperatorLineage()

Review Comment:
   If we don't have BQ job id, we can't call it's API to get lineage.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to