Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions airflow/providers/google/cloud/operators/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,11 @@ def execute(self, context: Context) -> list[str]:
orig_end = context["data_interval_end"]
except KeyError:
orig_start = pendulum.instance(context["execution_date"])
following_execution_date = context["dag"].following_schedule(context["execution_date"])
if following_execution_date is None:
orig_end = None
next_dagrun = context["dag"].next_dagrun_info(last_automated_dagrun=None, restricted=False)
if next_dagrun and next_dagrun.data_interval and next_dagrun.data_interval.end:
orig_end = next_dagrun.data_interval.end
else:
orig_end = pendulum.instance(following_execution_date)
orig_end = None

timespan_start = orig_start
if orig_end is None: # Only possible in Airflow before 2.2.
Expand Down
22 changes: 20 additions & 2 deletions tests/providers/google/cloud/operators/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pathlib import Path
from unittest import mock

import pendulum
import pytest

from airflow.providers.common.compat.openlineage.facet import (
Expand All @@ -40,6 +41,7 @@
GCSSynchronizeBucketsOperator,
GCSTimeSpanFileTransformOperator,
)
from airflow.timetables.base import DagRunInfo, DataInterval

TASK_ID = "test-gcs-operator"
TEST_BUCKET = "test-bucket"
Expand Down Expand Up @@ -395,7 +397,15 @@ def test_execute(self, mock_hook, mock_subprocess, mock_tempdir):
timespan_start = datetime(2015, 2, 1, 15, 16, 17, 345, tzinfo=timezone.utc)
timespan_end = timespan_start + timedelta(hours=1)
mock_dag = mock.Mock()
mock_dag.following_schedule = lambda x: x + timedelta(hours=1)
mock_dag.next_dagrun_info.side_effect = [
DagRunInfo(
run_after=pendulum.instance(timespan_start),
data_interval=DataInterval(
start=pendulum.instance(timespan_start),
end=pendulum.instance(timespan_end),
),
),
]
mock_ti = mock.Mock()
context = dict(
execution_date=timespan_start,
Expand Down Expand Up @@ -575,7 +585,15 @@ def test_get_openlineage_facets_on_complete(

timespan_start = datetime(2015, 2, 1, 15, 16, 17, 345, tzinfo=timezone.utc)
mock_dag = mock.Mock()
mock_dag.following_schedule = lambda x: x + timedelta(hours=1)
mock_dag.next_dagrun_info.side_effect = [
DagRunInfo(
run_after=pendulum.instance(timespan_start),
data_interval=DataInterval(
start=pendulum.instance(timespan_start),
end=None,
),
),
]
context = dict(
execution_date=timespan_start,
dag=mock_dag,
Expand Down