Content-Length: 316446 | pFad | https://github.com/apache/airflow/commit/07fe356de0743ca64d936738b78704f7c05774d1

6F GCSToBigQueryOperator Resolve `max_id_key` job retrieval and xcom ret… · apache/airflow@07fe356 · GitHub
Skip to content

Commit 07fe356

Browse files
authored
GCSToBigQueryOperator Resolve max_id_key job retrieval and xcom return (#26285)
* Resolve `max_id_key` job retrieval and xcom return * Fixing Flake8 Issue * Fixing Unit Test failure * Code fixes requested during review
1 parent b4f8a06 commit 07fe356

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

airflow/providers/google/cloud/transfers/gcs_to_bigquery.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ def execute(self, context: Context):
316316
warnings.simplefilter("ignore", DeprecationWarning)
317317
job_id = bq_hook.run_query(
318318
sql=select_command,
319+
location=self.location,
319320
use_legacy_sql=False,
320321
)
321-
row = list(bq_hook.get_job(job_id).result())
322+
row = list(bq_hook.get_job(job_id=job_id, location=self.location).result())
322323
if row:
323324
max_id = row[0] if row[0] else 0
324325
self.log.info(
@@ -327,5 +328,6 @@ def execute(self, context: Context):
327328
self.max_id_key,
328329
max_id,
329330
)
331+
return max_id
330332
else:
331333
raise RuntimeError(f"The {select_command} returned no rows!")

tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ def test_execute_explicit_project(self, bq_hook):
4545

4646
bq_hook.return_value.get_job.return_value.result.return_value = ('1',)
4747

48-
operator.execute(None)
48+
result = operator.execute(None)
49+
50+
assert result == '1'
4951

5052
bq_hook.return_value.run_query.assert_called_once_with(
5153
sql="SELECT MAX(id) FROM `test-project.dataset.table`",
54+
location=None,
5255
use_legacy_sql=False,
5356
)
5457

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/apache/airflow/commit/07fe356de0743ca64d936738b78704f7c05774d1

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy