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: remove primary key for the geographic performance reports #31432

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-bing-ads/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=1.0.0
LABEL io.airbyte.version=2.0.0
LABEL io.airbyte.name=airbyte/source-bing-ads
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 47f25999-dd5e-4636-8c39-e7cea2453331
dockerImageTag: 1.0.0
dockerImageTag: 2.0.0
dockerRepository: airbyte/source-bing-ads
githubIssueLabel: source-bing-ads
icon: bingads.svg
Expand All @@ -34,5 +34,8 @@ data:
1.0.0:
message: "Version 1.0.0 removes the primary keys from the geographic performance report streams. This will prevent the connector from losing data in the incremental append+dedup sync mode because of deduplication and incorrect primary keys. A data reset and schema refresh of all the affected streams is required for the changes to take effect."
upgradeDeadline: "2023-10-25"
2.0.0:
message: "This update is a follow-up to the previous major update - version 1.0.0. It completes what should have been done in version 1.0.0, but unfortunately was not. Version 2.0.0 removes the primary keys from the geographic performance report streams. This will prevent the connector from losing data in the incremental append+dedup sync mode because of deduplication and incorrect primary keys. A data reset and schema refresh of all the affected streams is required for the changes to take effect."
upgradeDeadline: "2023-10-31"
supportLevel: certified
metadataSpecVersion: "1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ class GeographicPerformanceReport(PerformanceReportsMixin, BingAdsStream):
cursor_field = "TimePeriod"
report_schema_name = "geographic_performance_report"

# Need to override the primary key here because the one inherited from the PerformanceReportsMixin
# is incorrect for the geographic performance reports
primary_key = None

report_columns = [
"AccountId",
"CampaignId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
#

import copy
from unittest.mock import Mock

import pendulum
import pytest
from bingads.v13.internal.reporting.row_report_iterator import _RowReportRecord, _RowValues
from source_bing_ads.reports import PerformanceReportsMixin, ReportsMixin
from source_bing_ads.source import SourceBingAds
from source_bing_ads.source import (
GeographicPerformanceReportDaily,
GeographicPerformanceReportHourly,
GeographicPerformanceReportMonthly,
GeographicPerformanceReportWeekly,
SourceBingAds,
)


class TestClient:
Expand Down Expand Up @@ -137,3 +145,23 @@ def test_report_get_start_date_performance_report_wo_stream_state():
stream_state = {}
account_id = "123"
assert reports_start_date.subtract(days=days_to_subtract) == test_report.get_start_date(stream_state, account_id)


@pytest.mark.parametrize(
"performance_report_cls",
(
GeographicPerformanceReportDaily,
GeographicPerformanceReportHourly,
GeographicPerformanceReportMonthly,
GeographicPerformanceReportWeekly,
),
)
def test_geographic_performance_report_pk(performance_report_cls):
config = {
"developer_token": "developer_token",
"client_id": "client_id",
"refresh_token": "refresh_token",
"reports_start_date": "2020-01-01T00:00:00Z",
}
stream = performance_report_cls(client=Mock(), config=config)
assert stream.primary_key is None
12 changes: 11 additions & 1 deletion docs/integrations/sources/bing-ads-migrations.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Bing Ads Migration Guide

## Upgrading to 2.0.0

This update is a follow-up to the previous major update - version 1.0.0. It completes what should have been done in version 1.0.0, but unfortunately was not.
It only affects the geographic performance reports streams.

Version 2.0.0 prevents the data loss by removing the primary keys from the `GeographicPerformanceReportMonthly`, `GeographicPerformanceReportWeekly`, `GeographicPerformanceReportDaily`, `GeographicPerformanceReportHourly` streams.
Due to multiple records with the same primary key, users could experience data loss in the incremental append+dedup mode because of deduplication.

For the changes to take effect, please reset your data and refresh the stream schemas after you have applied the upgrade.

## Upgrading to 1.0.0

This version update only affects the geographic performance reports streams.

Version 1.0.0 prevents the data loss by removing the primary keys from the `GeographicPerformanceReportMonthly`, `GeographicPerformanceReportWeekly`, `GeographicPerformanceReportDaily`, `GeographicPerformanceReportHourly` streams.
Due to multiple records with the same primary key, users could experience data loss in the incremental append+dedup mode because of deduplication.

For the changes to take effect, please reset your data and refresh the stream schemas after you have applied the upgrade.
For the changes to take effect, please reset your data and refresh the stream schemas after you have applied the upgrade.
1 change: 1 addition & 0 deletions docs/integrations/sources/bing-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ The Bing Ads API limits the number of requests for all Microsoft Advertising cli

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------|
| 2.0.0 | 2023-10-16 | [31432](https://github.com/airbytehq/airbyte/pull/31432) | Remove primary keys from the geographic performance reports - complete what was missed in version 1.0.0 |
| 1.0.0 | 2023-10-11 | [31277](https://github.com/airbytehq/airbyte/pull/31277) | Remove primary keys from the geographic performance reports. |
| 0.2.3 | 2023-09-28 | [30834](https://github.com/airbytehq/airbyte/pull/30834) | Wrap auth error with the config error. |
| 0.2.2 | 2023-09-27 | [30791](https://github.com/airbytehq/airbyte/pull/30791) | Fix missing fields for geographic performance reports. |
Expand Down
Loading