Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Source Bing Ads: add new stream Campaign Impression Performance Report (daily, hourly, weekly, monthly) #32059

Expand Up @@ -28,6 +28,8 @@ acceptance_tests:
bypass_reason: "Hourly reports are disabled, because sync is too long"
- name: campaign_performance_report_hourly
bypass_reason: "Hourly reports are disabled, because sync is too long"
- name: campaign_impression_performance_report_hourly
bypass_reason: "Empty report; hourly data fetched is limited to 180 days"
- name: keyword_performance_report_hourly
bypass_reason: "Hourly reports are disabled, because sync is too long"
- name: geographic_performance_report_hourly
Expand Down
Expand Up @@ -226,6 +226,46 @@
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_hourly",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_daily",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_weekly",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_monthly",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "keyword_performance_report_hourly",
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -16,7 +16,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 47f25999-dd5e-4636-8c39-e7cea2453331
dockerImageTag: 1.7.0
dockerImageTag: 1.8.0
dockerRepository: airbyte/source-bing-ads
documentationUrl: https://docs.airbyte.com/integrations/sources/bing-ads
githubIssueLabel: source-bing-ads
Expand Down
Expand Up @@ -4,7 +4,7 @@

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

import pendulum
import source_bing_ads.source
Expand All @@ -14,7 +14,6 @@
from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
from bingads.service_client import ServiceClient
from bingads.v13.internal.reporting.row_report import _RowReport
from bingads.v13.internal.reporting.row_report_iterator import _RowReportRecord
from bingads.v13.reporting import ReportingDownloadParameters
from suds import sudsobject

Expand Down Expand Up @@ -292,28 +291,6 @@ def get_report_request(
report_request.Columns = columns
return report_request

def parse_response(self, response: sudsobject.Object, **kwargs: Mapping[str, Any]) -> Iterable[Mapping]:
if response is not None:
for row in response.report_records:
yield {column: self.get_column_value(row, column) for column in self.report_columns}

yield from []

@staticmethod
def get_column_value(row: _RowReportRecord, column: str) -> Union[str, None, int, float]:
"""
Reads field value from row and transforms:
1. empty values to logical None
2. Percent values to numeric string e.g. "12.25%" -> "12.25"
"""
value = row.value(column)
if not value or value == "--":
return None
if "%" in value:
value = value.replace("%", "")

return value

def get_report_record_timestamp(self, datestring: str) -> int:
"""
Parse report date field based on aggregation type
Expand Down