Hello, I’m struggling with implementing a simple b...
# singer-tap-development
j
Hello, I’m struggling with implementing a simple behavior into my tap and I’d be thankful for any help. I have a case where I want to query a list of details across all projects. First, a parent stream queries a list of accessible projects. Then child streams query for details of each individual project (one stream per project). I want the results of all the child streams combined. I’m finding it very difficult to find any documentation on how to implement this 1:many mapping. Any guidance or references to related examples would be much appreciated. Here’s some simplified psuedocode of what I’m trying to accomplish.
Copy code
details = []
projects = requests.get(f"{url}/api/projects/search).json()

for project in projects:
    response = requests.get(f"{url}/api/{project}/detail).json()
    for detail in response:
        details.append(detail)
return {"details": details}
v
You're in luck the SDK does this for you! https://sdk.meltano.com/en/latest/parent_streams.html Note that it would help significantly if you could share your entire git repo as that snippet doesn't help me much In this case you're use a Parent Stream of Projects Your child stream would be ProjectDetails. Project Details stream name would be something like
project_details
and they would be "combined" as each record has the same stream, the target itself takes each record and pushes them into one place for you (normally a table in your DW called
project_details )
j
Hey Derek, thanks for responding. The part I’m missing though, is how do I get the parent to start up multiple distinct child ProjectDetail streams, each with a differing url path? Or if I just use one child stream as you described, how do I query multiple url paths?
v
j
Yes. Maybe it’s blatantly obvious, but I’m just missing it. I have an array in
get_child_context
record listing all the projects.
v
`
Copy code
path = "/groups/{group_id}/epics/{epic_iid}/issues"
`
that part of the example is a url path
j
yes, but how do I pass say 12 different values for {group_id}?
v
Read some of the examples / github repos that use the SDK
It's literally what this was designed for! 😄
Multiple teams come through
j
Ok, my question was a little misworded, or maybe I’m still missing something. How do you create multiple child streams from a single record in the parent stream.
v
yeild multiple records from the API response. Check out
get_records()
each project in your case is a record
j
ok thanks