I need to populate my schema based on custom field...
# singer-tap-development
v
I need to populate my schema based on custom field data. Each Project has custom fields for each Item. Hierarchy of Streams is Teams -> Project -> CustomFields. Issue is that I need to know the list of ProjectIds during discovery. Is there anyway to "hook" into that logic. I really want to say inside of the
schema
method of my
ItemStream
class. Pull data from the Projects stream, send some api requests off based on this data. This would automatically query Teams as it's the parent of Projects. Right now I"m going to just code what I need into
schema
but if I could hook into the existing Parent/Child relationship easily it'd be slick
a
Just so I understand the use case, can you give an example or two of dynamic properties which would come from the parent?
v
project_id
Specefically I need a list of all the
project_id
's
a
Sorry, to confirm: are the properties dynamic or the contents?
Or did you want to represent each project in a separate column?
v
I'll be specefic šŸ˜„ https://sprints.zoho.com/apidoc.html#Getitemfields GET request is
/team/{teamId}/projects/{projectId}/
I need that for the
Items
schema
a
Got it!!
v
Parent / Child relationships are all setup, and I have it working, but I need custom fields in there as well. It pairs nicely with the commment I just posted on @josh_lloyd’s MR šŸ™‚
a
So, in this example, presumably children of different parents have different schemas? And I guess, the target will merge as well as possible?
v
Good question No in this case all Items are going to have one schema. For Items that don't have that projects custom_field they'll just be null
Seems like the best tradeoff
But the trick is the one schema is dynamic due to Custom Fields from each project šŸ™‚
a
So, before sync, a dag is created internally in the SDK so that everything can be ordered correctly. I don't believe discovery uses the same ordering - but this could be changed to honor the dagified-ordering if it's not doing so already. Then, presumably when Stream.schema is called the first time, it could reference some result from the parent.
So, "possible, but probably not easy" is the upshot :)
v
šŸ˜„ Yeah I was look at
Tap
and
sync_all
load_streams
is the magic šŸ˜„ Is it worth the unwind from my end 🤷
This combined with having "dummy" streams would be useful in one other context I have with tap-googleads as well
a
I think
tap.discover_streams()
is the place to start. You'd basically want that method to look like
sync_all()
v
Makes sense, now to find the fastest way to get to what I need
Thanks
a
It sounds like a fun problem! While you're at it, you might run into this: https://gitlab.com/meltano/sdk/-/issues/93
We don't have documented patterns for "extra" requests calls - not a barrier for you but just want to call out it's a known area for improvement.
v
Got it! Thank you! I try real hard to force everything into streams to avoid that sometimes I think a bit too much about it šŸ˜„
Great issue though!