Skip to content

Commit

Permalink
facebook: ads_insights primary keys must be non-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
mdibaiee committed Mar 15, 2024
1 parent b5c4ce3 commit 8e54389
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
"type": ["null", "string"]
}
},
"type": ["object"]
"type": ["object"],
"required": ["actor_id", "event_time", "event_type", "object_id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,6 @@
}
}
}
}
},
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -1375,5 +1375,6 @@
"type": ["null", "string"]
}
},
"type": ["object"]
"type": ["object"],
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@
}
}
}
}
},
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -446,5 +446,6 @@
}
}
}
}
},
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,6 @@
"type": ["null", "number"]
}
},
"type": ["object"]
"type": ["object"],
"required": ["account_id", "ad_id", "date_start"]
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"properties": {
"ad_format_asset": { "type": ["null", "string"] },
"age": { "type": ["string"] },
"age": { "type": ["null", "string"] },
"app_id": { "type": ["null", "string"] },
"body_asset": { "type": ["null", "string"] },
"call_to_action_asset": { "type": ["null", "string"] },
"country": { "type": ["string"] },
"country": { "type": ["null", "string"] },
"description_asset": { "type": ["null", "string"] },
"device_platform": { "type": ["null", "string"] },
"dma": { "type": ["string"] },
"dma": { "type": ["null", "string"] },
"frequency_value": { "type": ["null", "string"] },
"gender": { "type": ["string"] },
"gender": { "type": ["null", "string"] },
"hourly_stats_aggregated_by_advertiser_time_zone": {
"type": ["null", "string"]
},
"hourly_stats_aggregated_by_audience_time_zone": {
"type": ["null", "string"]
},
"image_asset": { "type": ["null", "string"] },
"impression_device": { "type": ["string"] },
"impression_device": { "type": ["null", "string"] },
"link_url_asset": { "type": ["null", "string"] },
"place_page_id": { "type": ["null", "string"] },
"platform_position": { "type": ["string"] },
"platform_position": { "type": ["null", "string"] },
"product_id": { "type": ["null", "string"] },
"publisher_platform": { "type": ["string"] },
"region": { "type": ["string"] },
"publisher_platform": { "type": ["null", "string"] },
"region": { "type": ["null", "string"] },
"skan_conversion_id": { "type": ["null", "string"] },
"title_asset": { "type": ["null", "string"] },
"video_asset": { "type": ["null", "string"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@
"type": "string"
}
},
"type": ["object"]
"type": ["object"],
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
"width": {
"type": ["null", "integer"]
}
}
},
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@
"views": {
"type": ["null", "integer"]
}
}
},
"required": ["id"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def check_breakdowns(self):
def stream_slices(
self, sync_mode: SyncMode, cursor_field: List[str] = None, stream_state: Mapping[str, Any] = None
) -> Iterable[Optional[Mapping[str, Any]]]:

"""Slice by date periods and schedule async job for each period, run at most MAX_ASYNC_JOBS jobs at the same time.
This solution for Async was chosen because:
1. we should commit state after each successful job
Expand Down Expand Up @@ -297,6 +296,22 @@ def get_json_schema(self) -> Mapping[str, Any]:
if self.breakdowns:
breakdowns_properties = loader.get_schema("ads_insights_breakdowns")["properties"]
schema["properties"].update({prop: breakdowns_properties[prop] for prop in self.breakdowns})

for k in self.primary_key:
if k not in schema["properties"]:
continue

tys = schema["properties"][k]["type"]

if "null" in tys:
schema["properties"][k]["type"] = tys.remove("null")

if "required" not in schema:
schema["required"] = []

if k not in schema["required"]:
schema["required"].append(k)

return schema

@cached_property
Expand Down
Loading

0 comments on commit 8e54389

Please sign in to comment.