pankajastro commented on code in PR #31591:
URL: https://github.com/apache/airflow/pull/31591#discussion_r1247861257


##########
airflow/providers/google/cloud/hooks/bigquery.py:
##########
@@ -3103,29 +3103,16 @@ async def get_job_instance(
         with await self.service_file_as_context() as f:
             return Job(job_id=job_id, project=project_id, service_file=f, 
session=cast(Session, session))
 
-    async def get_job_status(
-        self,
-        job_id: str | None,
-        project_id: str | None = None,
-    ) -> str | None:
-        """Poll for job status asynchronously using gcloud-aio.
-
-        Note that an OSError is raised when Job results are still pending.
-        Exception means that Job finished with errors
-        """
+    async def get_job_status(self, job_id: str | None, project_id: str | None 
= None) -> str:
         async with ClientSession() as s:
-            try:
-                self.log.info("Executing get_job_status...")
-                job_client = await self.get_job_instance(project_id, job_id, s)
-                job_status_response = await job_client.result(cast(Session, s))
-                if job_status_response:
-                    job_status = "success"
-            except OSError:
-                job_status = "pending"
-            except Exception as e:
-                self.log.info("Query execution finished with errors...")
-                job_status = str(e)
-            return job_status
+            job_client = await self.get_job_instance(project_id, job_id, s)
+            job = await job_client.get_job()
+            status = job.get("status", {})
+            if status["state"] == "DONE":
+                if "errorResult" in status:
+                    return "error"
+                return "success"
+            return status["state"].lower()

Review Comment:
   Here job is in some intermediate state. error state is in L3113 



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