dylan
10/26/2022, 7:51 AM{
"type": "event",
"id": "string",
"attributes": {
"metric": "string",
"description": "string",
"timestamp": "string",
"properties": {},
"datetime": "string"
},
"title": "string",
"meta": {}
}
I'm not sure how to best get at the "datetime" property inside "attributes". Glancing over the methods inside the sdk it looks like replication keys can only be a top-level property (and maybe the singer spec explicitly states that too?). This is the structure I'm dealt with though so if anybody has any ideas, I'm all ears! 😅 Thanks!Reuben (Matatika)
10/26/2022, 12:28 PMattributes.timestamp
to a top-level property using post_process
and then set replication_key
to that new property key.
Not tested, but something like:
class TapStream(RESTStream):
replication_key = "timestamp"
// ...
def post_process(self, row: dict, context: Optional[dict] = None) -> Optional[dict]:
row[self.replication_key] = row["attributes"][self.replication_key]
return row
aaronsteers
10/26/2022, 4:51 PMpost_process()
is a quick and easy way to do that.
I'll add:
1. You can also remove/pop the attribute from the original location. (row[self.replication_key] = row["attributes"].pop(self.replication_key)
)
2. You'll want to make sure whatever schema
you define in the stream matches the updated version, not the original.aaronsteers
10/26/2022, 4:52 PMdylan
10/27/2022, 7:11 AMdylan
10/27/2022, 7:11 AM