In my custom tap, how can I access the catalog pas...
# plugins-general
r
In my custom tap, how can I access the catalog passed via
--catalog catalog.json
so I don’t have to rediscover my schema? Or is that catalog.json only sent to the target
Or is there another standard way of caching stream.schema
e
Does your tap perform dynamic discovery, or is the catalog mostly static?
r
Yeah dynamic discovery I’ve got a catalog.json that I’d like to reuse on subsequent runs. Motivation: ensure that everything looks like we expected it to when we locked in the catalog.json
Finally picked this up again, implementing catalog discovery. Is it a bug that
Stream.apply_catalog
doesn’t actually grab a catalog’s schema, even though its docs say it does? Happy to submit a PR if so https://github.com/meltano/sdk/blob/e64e1087cd654dee33a061673eb453fb5b558b44/singer_sdk/streams/core.py#L1214
e
I think the docstring is a bit misleading. The catalog does specify the schema, but the catalog's schema is used in a different place: https://github.com/meltano/sdk/blob/e79d755ff8f16264f3fd45787dd3ac8eeba31fd6/singer_sdk/mapper.py#L678-L693
Are you seeing different behavior?
r
Wait that’s in mapper? I couldn’t for the life of me figure out how to get this simple behaviour out of the box while developing a new tap: 1. Run
--discover > catalog.json
2. Run
--catalog catalog.json
Took a while to wrap my head around all the existing streams logic. Ended up overriding
Tap.discover_streams
and
Stream.apply_catalog
to get the behaviour I was looking for
e
Yeah, mappers can fan out a single stream into multiple ones so they get passed the input schema. By default the mapper uses the schema straight from the input catalog.
r
Ok that makes sense, not using mappers in this scenario here. What’s the best way to implement the behaviour I mentioned above? So much of Meltano is a black box to me, like how
tap.properties.json
is generated etc
Also tried to find a few good examples of taps that do this but the ones I found were all on old APIs
e
r
That’s what my current version is based on! Took a while to get through the tangle of similar-looking functions calling each other. Really appreciate you sharing. If that’s the best we’ve got as an example, then I do think we’re lacking a bit. What makes Meltano so promising to me is its extensibility, but a cookbook of examples or basic API docs would go a long way here. Maybe I can contribute
e
We do have https://sdk.meltano.com/en/v0.36.1/classes/singer_sdk.SQLTap.html, but I we're certainly open to improvements in docs structure, content and discoverability 😁. What in particular do you think is missing?
r
I like the page of recipes, but it’s very basic and some of it outdated. Even a link to the SQL Tap there would help discover “how to write your own mapper”
In fact, most of what I’ve learned I’ve learned from reading through source code. Even a list of best-in-class plugins that follow the most current best practices would be helpful