You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "mobuchowski (via GitHub)" <gi...@apache.org> on 2023/05/22 11:06:42 UTC

[GitHub] [airflow] mobuchowski commented on a diff in pull request #31293: openlineage, bigquery: add openlineage method support for BigQueryExecuteQueryOperator

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


##########
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

Review Comment:
   This is a design choice here, both are possible. 
   
   Thinking on it more, raising might be better, since this methods aren't supposed to be called outside of OpenLineage integration - and if OpenLineage integration calls it, the imports should work. So the raise situation is rather impossible outside of a bug.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org