You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/08/25 23:47:50 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #5906: [AIRFLOW-5304][depends on AIRFLOW-5306] Fix extra links in BigQueryOperator for task with muliple queriess

mik-laj commented on a change in pull request #5906: [AIRFLOW-5304][depends on AIRFLOW-5306] Fix extra links in BigQueryOperator for task with muliple queriess
URL: https://github.com/apache/airflow/pull/5906#discussion_r317420179
 
 

 ##########
 File path: airflow/contrib/operators/bigquery_operator.py
 ##########
 @@ -45,6 +45,30 @@ def get_link(self, operator, dttm):
             job_id=job_id) if job_id else ''
 
 
+class BigQueryConsoleIndexableLink(BaseOperatorLink):
+    """
+    Helper class for constructing BigQuery link.
+    """
+
+    def __init__(self, index) -> None:
+        super().__init__()
+        self.index = index
+
+    @property
+    def name(self) -> str:
+        return 'BigQuery Console #{index}'.format(index=self.index + 1)
+
+    def get_link(self, operator, dttm):
+        ti = TaskInstance(task=operator, execution_date=dttm)
+        job_ids = ti.xcom_pull(task_ids=operator.task_id, key='job_id')
+        if not job_ids:
+            return None
+        if len(job_ids) < self.index:
+            return None
+        job_id = job_ids[self.index]
+        return 'https://console.cloud.google.com/bigquery?j={job_id}'.format(job_id=job_id)
 
 Review comment:
   Updated. :-D 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services