Is there any examples of/ suggested ways for child...
# singer-tap-development
g
Is there any examples of/ suggested ways for child streams that require all records from a parent stream? In this case, one endpoint tells me the available fields that can be passed as a param in the child stream, and doing the child stream one field at a time is pretty time consuming 😬
a
I think you should be able to pass the while dict ?
1 sec, let me check my examples
Copy code
class ParentStream(...):
    ...

    def get_child_context(self, record: dict, context: Optional[dict]) -> dict:
        """Return a context dictionary for child streams."""
        return record


class ChildStream(ParentStream):
    parent_stream_type = ParentStream
    ...

    # Then you can do something like....
    def post_process(self, row: dict, context: Optional[dict] = None) -> dict:
        for field in context.keys():
            row[key] = context[field]
        return row
@gary_james does that help ?
g
I think this would return all items for a single record from the parent stream, no? As opposed to all records from the parent? I might be reading it wrong tho 😬
a
Maybe I was misreading your original question. For a given record of a child stream are you saying you want to access all records from the parent stream? iow all of the ‘uncle/aunt’ records ?
g
Yes, that’s it, my example wasn’t great 😂
As get_records seems to handle passing the context to the child stream im guessing I’d have to override that, tho it’s quite a hefty bit of functionality
a
Yeah a bit deeper than my knowledge of the underlying class