Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
1) Modified schema for video_ads stream.
2) Added transform logic to add ad_context fields to root level.
  • Loading branch information
shantanu73 committed Nov 2, 2023
1 parent 4c0c8bd commit 393dfb3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tap_linkedin_ads/schemas/video_ads.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@
"integer"
]
},
"status": {
"type": [
"null",
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"type": {
"type": [
"null",
"string"
]
},
"account": {
"type": [
"null",
"string"
]
},
"ad_context": {
"type": [
"null",
Expand Down
13 changes: 13 additions & 0 deletions tap_linkedin_ads/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ def transform_creatives(data_dict):

return new_dict

# Copy ad context fields to root level
def transform_ad_context_fields(data_dict):
if 'ad_context' in data_dict:
if 'dsc_status' in data_dict['ad_context']:
data_dict['status'] = data_dict['ad_context']['dsc_status']
if 'dsc_name' in data_dict['ad_context']:
data_dict['name'] = data_dict['ad_context']['dsc_name']
if 'dsc_ad_type' in data_dict['ad_context']:
data_dict['type'] = data_dict['ad_context']['dsc_ad_type']
if 'dsc_ad_account' in data_dict['ad_context']:
data_dict['account'] = data_dict['ad_context']['dsc_ad_account']
return data_dict

# Create ID field for each URN
def transform_urn(data_dict):
Expand Down Expand Up @@ -295,6 +307,7 @@ def transform_data(data_dict, stream_name):
this_dict = transform_campaigns(this_dict)
elif stream_name == 'creatives':
this_dict = transform_creatives(this_dict)
this_dict = transform_ad_context_fields(this_dict)
this_dict = transform_urn(this_dict)

new_dict['elements'][i] = this_dict
Expand Down

0 comments on commit 393dfb3

Please sign in to comment.