Skip to content

Commit

Permalink
🎉 Source Google Ads: add *_label streams (#11221)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgao authored Mar 23, 2022
1 parent 98ee6f5 commit d61af1b
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
- name: Google Ads
sourceDefinitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
dockerRepository: airbyte/source-google-ads
dockerImageTag: 0.1.29
dockerImageTag: 0.1.30
documentationUrl: https://docs.airbyte.io/integrations/sources/google-ads
icon: google-adwords.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-google-ads:0.1.29"
- dockerImage: "airbyte/source-google-ads:0.1.30"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/google-ads"
connectionSpecification:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ RUN pip install .

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

LABEL io.airbyte.version=0.1.29
LABEL io.airbyte.version=0.1.30
LABEL io.airbyte.name=airbyte/source-google-ads
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
REPORT_MAPPING = {
"accounts": "customer",
"ad_group_ads": "ad_group_ad",
"ad_group_ad_labels": "ad_group_ad_label",
"ad_groups": "ad_group",
"ad_group_labels": "ad_group_label",
"campaigns": "campaign",
"campaign_labels": "campaign_label",
"account_performance_report": "customer",
"ad_group_ad_report": "ad_group_ad",
"display_keyword_performance_report": "display_keyword_view",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"ad_group_ad.ad.resource_name": {
"type": ["null", "integer"]
},
"ad_group_ad_label.resource_name": {
"type": ["null", "string"]
},
"label.name": {
"type": ["null", "integer"]
},
"label.resource_name": {
"type": ["null", "integer"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"ad_group.resource_name": {
"type": ["null", "integer"]
},
"ad_group_label.resource_name": {
"type": ["null", "string"]
},
"label.name": {
"type": ["null", "integer"]
},
"label.resource_name": {
"type": ["null", "integer"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"campaign.resource_name": {
"type": ["null", "string"]
},
"campaign_label.resource_name": {
"type": ["null", "string"]
},
"label.name": {
"type": ["null", "integer"]
},
"label.resource_name": {
"type": ["null", "integer"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
from .streams import (
AccountPerformanceReport,
Accounts,
AdGroupAdLabels,
AdGroupAdReport,
AdGroupAds,
AdGroupLabels,
AdGroups,
CampaignLabels,
Campaigns,
ClickView,
DisplayKeywordPerformanceReport,
Expand Down Expand Up @@ -112,9 +115,12 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:

streams = [
AdGroupAds(**incremental_stream_config),
AdGroupAdLabels(google_api),
AdGroups(**incremental_stream_config),
AdGroupLabels(google_api),
Accounts(**incremental_stream_config),
Campaigns(**incremental_stream_config),
CampaignLabels(google_api),
ClickView(**incremental_stream_config),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

from abc import ABC
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Union

import pendulum
from airbyte_cdk.models import SyncMode
Expand Down Expand Up @@ -111,7 +111,9 @@ class IncrementalGoogleAdsStream(GoogleAdsStream, ABC):
primary_key = None
range_days = 15 # date range is set to 15 days, because for conversion_window_days default value is 14. Range less than 15 days will break the integration tests.

def __init__(self, start_date: str, conversion_window_days: int, time_zone: [pendulum.timezone, str], end_date: str = None, **kwargs):
def __init__(
self, start_date: str, conversion_window_days: int, time_zone: Union[pendulum.timezone, str], end_date: str = None, **kwargs
):
self.conversion_window_days = conversion_window_days
self._start_date = start_date
self.time_zone = time_zone
Expand Down Expand Up @@ -231,6 +233,15 @@ class Campaigns(IncrementalGoogleAdsStream):
primary_key = ["campaign.id", "segments.date"]


class CampaignLabels(GoogleAdsStream):
"""
Campaign labels stream: https://developers.google.com/google-ads/api/fields/v8/campaign_label
"""

# Note that this is a string type. Google doesn't return a more convenient identifier.
primary_key = ["campaign_label.resource_name"]


class AdGroups(IncrementalGoogleAdsStream):
"""
AdGroups stream: https://developers.google.com/google-ads/api/fields/v8/ad_group
Expand All @@ -239,6 +250,15 @@ class AdGroups(IncrementalGoogleAdsStream):
primary_key = ["ad_group.id", "segments.date"]


class AdGroupLabels(GoogleAdsStream):
"""
Ad Group Labels stream: https://developers.google.com/google-ads/api/fields/v8/ad_group_label
"""

# Note that this is a string type. Google doesn't return a more convenient identifier.
primary_key = ["ad_group_label.resource_name"]


class AdGroupAds(IncrementalGoogleAdsStream):
"""
AdGroups stream: https://developers.google.com/google-ads/api/fields/v8/ad_group_ad
Expand All @@ -247,6 +267,15 @@ class AdGroupAds(IncrementalGoogleAdsStream):
primary_key = ["ad_group_ad.ad.id", "segments.date"]


class AdGroupAdLabels(GoogleAdsStream):
"""
Ad Group Ad Labels stream: https://developers.google.com/google-ads/api/fields/v8/ad_group_ad_label
"""

# Note that this is a string type. Google doesn't return a more convenient identifier.
primary_key = ["ad_group_ad_label.resource_name"]


class AccountPerformanceReport(IncrementalGoogleAdsStream):
"""
AccountPerformanceReport stream: https://developers.google.com/google-ads/api/fields/v8/customer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_chunk_date_range():
def test_streams_count(config):
source = SourceGoogleAds()
streams = source.streams(config)
expected_streams_number = 16
expected_streams_number = 19
assert len(streams) == expected_streams_number


Expand Down
5 changes: 5 additions & 0 deletions docs/integrations/sources/google-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ This source is capable of syncing the following tables and their data:

* [accounts](https://developers.google.com/google-ads/api/fields/v8/customer)
* [ad\_group\_ads](https://developers.google.com/google-ads/api/fields/v8/ad_group_ad)
* [ad\_group\_ad\_labels](https://developers.google.com/google-ads/api/fields/v8/ad_group_ad_label)
* [ad\_groups](https://developers.google.com/google-ads/api/fields/v8/ad_group)
* [ad\_group\_labels](https://developers.google.com/google-ads/api/fields/v8/ad_group_label)
* [campaigns](https://developers.google.com/google-ads/api/fields/v8/campaign)
* [campaign\_labels](https://developers.google.com/google-ads/api/fields/v8/campaign_label)
* [click\_view](https://developers.google.com/google-ads/api/reference/rpc/v8/ClickView)
* [keyword](https://developers.google.com/google-ads/api/fields/v8/keyword_view)
* [geographic](https://developers.google.com/google-ads/api/fields/v8/geographic_view)

Note that `ad_groups`, `ad_group_ads`, and `campaigns` contain a `labels` field, which should be joined against their respective `*_labels` streams if you want to view the actual labels. For example, the `ad_groups` stream contains an `ad_group.labels` field, which you would join against the `ad_group_labels` stream's `label.resource_name` field.

#### Report Tables

Expand Down Expand Up @@ -102,6 +106,7 @@ This source is constrained by whatever API limits are set for the Google Ads tha

| Version | Date | Pull Request | Subject |
|:---------|:-----------| :--- |:---------------------------------------------------------------------------------------------|
| `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.1.29` | 2022-03-22 | [10919](https://github.com/airbytehq/airbyte/pull/10919) | Fix user location report schema and add to acceptance tests |
| `0.1.28` | 2022-02-25 | [10372](https://github.com/airbytehq/airbyte/pull/10372) | Add network fields to click view stream |
| `0.1.27` | 2022-02-16 | [10315](https://github.com/airbytehq/airbyte/pull/10315) | Make `ad_group_ads` and other streams support incremental sync. |
Expand Down

0 comments on commit d61af1b

Please sign in to comment.