Skip to content

Commit

Permalink
Fix BigQuery system tests (#24013)
Browse files Browse the repository at this point in the history
* Change execution_date to data_interval_start in BigQueryInsertJobOperator job_id

Change-Id: Ie1f3bba701169ceb2b39d693da320564de145c0c

* Change jinja template path to relative path

Change-Id: I6cced215124f69e9f4edf8ac08bb71d3ec3c8afc

Co-authored-by: Bartlomiej Hirsz <[email protected]>
  • Loading branch information
bhirsz and Bartlomiej Hirsz committed Jun 4, 2022
1 parent 13c62b5 commit c01a5a5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/operators/bigquery.py
Expand Up @@ -2130,7 +2130,7 @@ def _job_id(self, context):
if self.job_id:
return f"{self.job_id}_{uniqueness_suffix}"

exec_date = context['execution_date'].isoformat()
exec_date = context['logical_date'].isoformat()
job_id = f"airflow_{self.dag_id}_{self.task_id}_{exec_date}_{uniqueness_suffix}"
return re.sub(r"[:\-+.]", "_", job_id)

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/google/cloud/operators/test_bigquery.py
Expand Up @@ -1062,7 +1062,7 @@ def test_execute_no_force_rerun(self, mock_hook, mock_md5):
def test_job_id_validity(self, mock_md5, test_dag_id, expected_job_id):
hash_ = "hash"
mock_md5.return_value.hexdigest.return_value = hash_
context = {"execution_date": datetime(2020, 1, 23)}
context = {"logical_date": datetime(2020, 1, 23)}
configuration = {
"query": {
"query": "SELECT * FROM any",
Expand Down
Expand Up @@ -21,7 +21,6 @@
"""
import os
from datetime import datetime
from pathlib import Path

from airflow import models
from airflow.operators.bash import BashOperator
Expand All @@ -40,7 +39,7 @@
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
PROJECT_ID = os.environ.get("SYSTEM_TESTS_GCP_PROJECT")
LOCATION = "us-east1"
QUERY_SQL_PATH = str(Path(__file__).parent / "resources" / "example_bigquery_query.sql")
QUERY_SQL_PATH = "resources/example_bigquery_query.sql"

TABLE_1 = "table1"
TABLE_2 = "table2"
Expand Down

0 comments on commit c01a5a5

Please sign in to comment.