Skip to content

Commit 707b2a2

Browse files
authored
🐛 Source Google Ads: End date should not be in the future (#11513)
1 parent f059f42 commit 707b2a2

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
- name: Google Ads
267267
sourceDefinitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
268268
dockerRepository: airbyte/source-google-ads
269-
dockerImageTag: 0.1.32
269+
dockerImageTag: 0.1.33
270270
documentationUrl: https://docs.airbyte.io/integrations/sources/google-ads
271271
icon: google-adwords.svg
272272
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@
25702570
supportsNormalization: false
25712571
supportsDBT: false
25722572
supported_destination_sync_modes: []
2573-
- dockerImage: "airbyte/source-google-ads:0.1.32"
2573+
- dockerImage: "airbyte/source-google-ads:0.1.33"
25742574
spec:
25752575
documentationUrl: "https://docs.airbyte.com/integrations/sources/google-ads"
25762576
connectionSpecification:

airbyte-integrations/connectors/source-google-ads/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ RUN pip install .
1313

1414
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1515

16-
LABEL io.airbyte.version=0.1.32
16+
LABEL io.airbyte.version=0.1.33
1717
LABEL io.airbyte.name=airbyte/source-google-ads

airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from airbyte_cdk.sources import AbstractSource
1212
from airbyte_cdk.sources.streams import Stream
1313
from google.ads.googleads.errors import GoogleAdsException
14-
from pendulum import timezone
14+
from pendulum import parse, timezone, today
1515
from pendulum.tz.timezone import Timezone
1616

1717
from .custom_query_stream import CustomQuery
@@ -51,12 +51,16 @@ def get_credentials(config: Mapping[str, Any]) -> Mapping[str, Any]:
5151

5252
@staticmethod
5353
def get_incremental_stream_config(google_api: GoogleAds, config: Mapping[str, Any], tz: Union[timezone, str] = "local"):
54+
true_end_date = None
55+
configured_end_date = config.get("end_date")
56+
if configured_end_date is not None:
57+
true_end_date = min(today(), parse(configured_end_date)).to_date_string()
5458
incremental_stream_config = dict(
5559
api=google_api,
5660
conversion_window_days=config["conversion_window_days"],
5761
start_date=config["start_date"],
5862
time_zone=tz,
59-
end_date=config.get("end_date"),
63+
end_date=true_end_date,
6064
)
6165
return incremental_stream_config
6266

airbyte-integrations/connectors/source-google-ads/unit_tests/test_source.py

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66
from airbyte_cdk import AirbyteLogger
77
from freezegun import freeze_time
8+
from pendulum import today
89
from source_google_ads.custom_query_stream import CustomQuery
910
from source_google_ads.google_ads import GoogleAds
1011
from source_google_ads.source import SourceGoogleAds
@@ -438,3 +439,11 @@ def test_check_connection_should_fail_when_api_call_fails(mocker):
438439
)
439440
assert not check_successful
440441
assert message.startswith("Unable to connect to Google Ads API with the provided credentials")
442+
443+
444+
def test_end_date_is_not_in_the_future():
445+
source = SourceGoogleAds()
446+
config = source.get_incremental_stream_config(
447+
None, {"end_date": today().add(days=1).to_date_string(), "conversion_window_days": 14, "start_date": "2020-01-23"}
448+
)
449+
assert config.get("end_date") == today().to_date_string()

docs/integrations/sources/google-ads.md

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ This source is constrained by whatever API limits are set for the Google Ads tha
106106

107107
| Version | Date | Pull Request | Subject |
108108
|:---------|:-----------| :--- |:---------------------------------------------------------------------------------------------|
109+
| `0.1.33` | 2022-03-29 | [11513](https://github.com/airbytehq/airbyte/pull/11513) | When `end_date` is configured in the future, use today's date instead. |
109110
| `0.1.32` | 2022-03-24 | [11371](https://github.com/airbytehq/airbyte/pull/11371) | Improve how connection check returns error messages |
110111
| `0.1.31` | 2022-03-23 | [11301](https://github.com/airbytehq/airbyte/pull/11301) | Update docs and spec to clarify usage |
111112
| `0.1.30` | 2022-03-23 | [11221](https://github.com/airbytehq/airbyte/pull/11221) | Add `*_labels` streams to fetch the label text rather than their IDs |

0 commit comments

Comments
 (0)