Good day (again). Has anyone ever delt with nested...
# singer-tap-development
s
Good day (again). Has anyone ever delt with nested data that contains the id, but we also want to access the rest of the data? something in the form of:
Copy code
{
 identifiers{ id: 12345}
 data: {all_that_good_shit: ...}
}
I'm trying to set my replication key and primary key as a nested property, but the sdk really dont like that
Nested primary_keys / replication_keys and singer don't go together (maybe I'm wrong about this but that's my experience thus far). So you have to bring them to the top. It'd be curious someday to have Singer's primary and replication keys use json paths as that'd solve this without having to touch the data
e
It'd be curious someday to have Singer's primary and replication keys use json paths as that'd solve this without having to touch the data
@visch That may be relatively easy to implement in the SDK 🙂. Would you mind filing an issue? I think the only place we'd need to update is https://gitlab.com/meltano/sdk/-/blob/241b38e8b6cdfa6f3397d9c70e7b9082b4594554/singer_sdk/helpers/_state.py#L219
How'd down stream targets know where to look? Are you thinking of having the sdk generate
_sdc_primary_key
?
e
Ah I completely missed the primary key bit 🤔.
Are you thinking of having the SDK generate
_sdc_primary_key
?
That is a good option. The SDK already appends context keys in child streams, for example.
s
@visch yours is much prettier than mine. I'm just trying to get some data out atm, so look at this baby 😉 :
Copy code
def parse_response(self, response: requests.Response) -> Iterable[dict]:
        """Parse the response and return an iterator of result rows."""
        response.raise_for_status()
        input = response.json()

        for elem in input["results"]:
            elem["id"] = elem["engagement"]["id"]
            elem["lastUpdated"] = elem["engagement"]["lastUpdated"]
        yield from extract_jsonpath(self.records_jsonpath, input=input)
v
credit to @josh_lloyd