Skip to content

Commit 9eae446

Browse files
🚨🚨 Source Linkedin Ads: Update pivotValues pk type for Ad Analytics streams (#37531)
1 parent d790b7d commit 9eae446

File tree

10 files changed

+82
-18
lines changed

10 files changed

+82
-18
lines changed

‎airbyte-integrations/connectors/source-linkedin-ads/integration_tests/expected_records.jsonl

+14-14
Large diffs are not rendered by default.

‎airbyte-integrations/connectors/source-linkedin-ads/metadata.yaml

+18-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data:
1111
connectorSubtype: api
1212
connectorType: source
1313
definitionId: 137ece28-5434-455c-8f34-69dc3782f451
14-
dockerImageTag: 1.0.1
14+
dockerImageTag: 2.0.0
1515
dockerRepository: airbyte/source-linkedin-ads
1616
documentationUrl: https://docs.airbyte.com/integrations/sources/linkedin-ads
1717
githubIssueLabel: source-linkedin-ads
@@ -48,6 +48,23 @@ data:
4848
- "ad_member_seniority_analytics"
4949
- "ad_member_region_analytics"
5050
- "ad_member_company_analytics"
51+
2.0.0:
52+
message: This upgrade changes primary key for *-analytics streams from pivotValues[array of strings] to string_of_pivot_values[string] so that it is compatible with more destination types.
53+
upgradeDeadline: "2024-05-14"
54+
scopedImpact:
55+
- scopeType: stream
56+
impactedScopes:
57+
- "ad_campaign_analytics"
58+
- "ad_creative_analytics"
59+
- "ad_impression_device_analytics"
60+
- "ad_member_company_size_analytics"
61+
- "ad_member_country_analytics"
62+
- "ad_member_job_function_analytics"
63+
- "ad_member_job_title_analytics"
64+
- "ad_member_industry_analytics"
65+
- "ad_member_seniority_analytics"
66+
- "ad_member_region_analytics"
67+
- "ad_member_company_analytics"
5168
suggestedStreams:
5269
streams:
5370
- accounts

‎airbyte-integrations/connectors/source-linkedin-ads/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "1.0.1"
6+
version = "2.0.0"
77
name = "source-linkedin-ads"
88
description = "Source implementation for Linkedin Ads."
99
authors = [ "Airbyte <[email protected]>",]

‎airbyte-integrations/connectors/source-linkedin-ads/source_linkedin_ads/analytics_streams.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class LinkedInAdsAnalyticsStream(IncrementalLinkedinAdsStream, ABC):
127127

128128
endpoint = "adAnalytics"
129129
# For Analytics streams, the primary_key is the entity of the pivot [Campaign URN, Creative URN, etc.] + `end_date`
130-
primary_key = ["pivotValues", "end_date"]
130+
primary_key = ["string_of_pivot_values", "end_date"]
131131
cursor_field = "end_date"
132132
records_limit = 15000
133133
FIELDS_CHUNK_SIZE = 18

‎airbyte-integrations/connectors/source-linkedin-ads/source_linkedin_ads/schemas/ad_analytics.json

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
"type": ["null", "string"]
114114
}
115115
},
116+
"string_of_pivot_values": {
117+
"type": ["null", "string"]
118+
},
116119
"postClickJobApplications": {
117120
"type": ["null", "number"]
118121
},

‎airbyte-integrations/connectors/source-linkedin-ads/source_linkedin_ads/utils.py

+9
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ def transform_col_names(record: Dict, dict_keys: list = []) -> Mapping[str, Any]
305305
return record
306306

307307

308+
def transform_pivot_values(record: Dict) -> Mapping[str, Any]:
309+
pivot_values = record.get("pivotValues", [])
310+
record["string_of_pivot_values"] = ",".join(pivot_values)
311+
return record
312+
313+
308314
def transform_data(records: List) -> Iterable[Mapping]:
309315
"""
310316
We need to transform the nested complex data structures into simple key:value pair,
@@ -323,6 +329,9 @@ def transform_data(records: List) -> Iterable[Mapping]:
323329
if "variables" in record:
324330
record = transform_variables(record)
325331

332+
if "pivotValues" in record:
333+
record = transform_pivot_values(record)
334+
326335
record = transform_col_names(record, DESTINATION_RESERVED_KEYWORDS)
327336

328337
yield record

‎airbyte-integrations/connectors/source-linkedin-ads/unit_tests/utils_tests/samples/test_data_for_tranform.py

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
}
6666
},
6767
"pivot": "TEST_PIVOT_VALUE",
68+
"pivotValues": ["TEST_PIVOT_VALUE_1", "TEST_PIVOT_VALUE_2"]
6869
}
6970
]
7071

@@ -142,5 +143,7 @@
142143
"start_date": "2021-08-13",
143144
"end_date": "2021-08-13",
144145
"_pivot": "TEST_PIVOT_VALUE",
146+
"string_of_pivot_values": "TEST_PIVOT_VALUE_1,TEST_PIVOT_VALUE_2",
147+
"pivotValues": ["TEST_PIVOT_VALUE_1", "TEST_PIVOT_VALUE_2"]
145148
}
146149
]

‎airbyte-integrations/connectors/source-linkedin-ads/unit_tests/utils_tests/test_transform_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from source_linkedin_ads.utils import transform_data
77

88

9-
def test_transfrom_data():
9+
def test_transform_data():
1010
"""
1111
As far as we transform the data within the generator object,
1212
we use list() to have the actual output for the test assertion.

‎docs/integrations/sources/linkedin-ads-migrations.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# LinkedIn Ads Migration Guide
22

3+
## Upgrading to 2.0.0
4+
5+
Version 2.0.0 introduces changes in the primary key selected for all *-analytics streams (including custom ones) from pivotValues[array of strings] to string_of_pivot_values[string] so that it is compatible with more destination types.
6+
7+
- "ad_campaign_analytics"
8+
- "ad_creative_analytics"
9+
- "ad_impression_device_analytics"
10+
- "ad_member_company_size_analytics"
11+
- "ad_member_country_analytics"
12+
- "ad_member_job_function_analytics"
13+
- "ad_member_job_title_analytics"
14+
- "ad_member_industry_analytics"
15+
- "ad_member_seniority_analytics"
16+
- "ad_member_region_analytics"
17+
- "ad_member_company_analytics"
18+
19+
## Migration Steps
20+
21+
Clearing your data is required for the affected streams in order to continue syncing successfully. To clear your data for the affected streams, follow the steps below:
22+
23+
1. Select **Connections** in the main navbar and select the connection(s) affected by the update.
24+
2. Select the **Schema** tab.
25+
1. Select **Refresh source schema** to bring in any schema changes. Any detected schema changes will be listed for your review.
26+
2. Select **OK** to approve changes.
27+
3. Select **Save changes** at the bottom of the page.
28+
1. Ensure the **Clear affected streams** option is checked to ensure your streams continue syncing successfully with the new schema.
29+
4. Select **Save connection**.
30+
31+
This will clear the data in your destination for the subset of streams with schema changes. After the clear succeeds, trigger a sync by clicking **Sync Now**. For more information on clearing your data in Airbyte, see [this page](https://docs.airbyte.com/operator-guides/reset).
32+
33+
334
## Upgrading to 1.0.0
435

536
Version 1.0.0 introduces changes in the primary key selected for all *-analytics streams (including custom ones).

‎docs/integrations/sources/linkedin-ads.md

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ After 5 unsuccessful attempts - the connector will stop the sync operation. In s
171171

172172
| Version | Date | Pull Request | Subject |
173173
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|
174+
| 2.0.0 | 2024-04-24 | [37531](https://github.com/airbytehq/airbyte/pull/37531) | Change primary key for Analytics Streams |
174175
| 1.0.1 | 2024-03-28 | [34152](https://github.com/airbytehq/airbyte/pull/34152) | Proceed pagination if return less than expected |
175176
| 1.0.0 | 2024-04-10 | [36927](https://github.com/airbytehq/airbyte/pull/36927) | Update primary key for Analytics Streams |
176177
| 0.8.0 | 2024-03-19 | [36267](https://github.com/airbytehq/airbyte/pull/36267) | Pin airbyte-cdk version to `^0` |

0 commit comments

Comments
 (0)