Hi folks! A question: I’m using the Python SDK. Is there a graceful way to handle nested objects in an API response?
In my case, I have an API response, and one of the fields is a list of other objects. Logically, I think those other objects should go into their own table, but I’m not quite sure how to do that.
In general, for the official CloudQuery plugins, we typically avoid splitting a single API response into multiple tables, instead preferring to keep the tables aligned with the raw API response using a JSON column and allowing users to add further data transformation as needed at query time.
Having said that, anybody writing their own plugins is obviously free to pick what works best for them. What you are proposing should be possible by adding an additional table via the relations field. This will introduce a dependent table whose TableResolver is called once per row in the parent table. This resolver would then be used to extract the nested data (in your case the list of plans).
I hope this helps; let me know if you have any further questions.
I think it does, on both counts! Thank you!
I suppose I could use a JSON column type… but I’m hoping to output to an SQL format and I don’t think that’ll make it easy to query against the data in those fields. But a relation would certainly do it.