Hi, I'm using meltano to load some data to Postgre...
# getting-started
k
Hi, I'm using meltano to load some data to Postgres. Wandering how I should handle unraveling nested data? My table has columns such as
customer_id, start_date, plan
, where the 'plan' data looks like:
Copy code
{
  "id": "price_abc",
  "active": true,
  "amount": 999,
  "object": "plan",
  "created": "2022-09-09",
  "product": "prod_abcd",
  "currency": "usd"
}
and another tap-associated 'metadata' col has data like
{emails: <mailto:inigo@montoya.com|inigo@montoya.com>
. ...I changed the postgres
data_flattening_max_level
to 1, which flattened out 'Plan' attributes, but not the 'metadata' attributes. Some questions: •
meltano select tap-stripe --list --all
shows the attribute subscriptions.metadata, but not s_ubscriptions.metadata.email_. Does this mean i'd have to handle subscriptions.metadata unraveling later through DBT/ in transformation? • Is it better practice to explicitly pick and choose specific grandchild streams(?), like _subscriptions.plan.amoun_t, subsciptions.plan.id, or to increase the flattening level?
s
How deep is your metadata column? If you know the depth, you should simply be able to change the data_flattening_max_level=YOUR_DEPTH (e.g. 3) and the columns should be created automatically. - Or is it an issue with the quotes that just one type is flattened? In general you could also use a mapper to achieve this, in case you want to do more things before loading. (https://docs.meltano.com/concepts/plugins#mappers)
FWIW to the more general best practices question: I would always opt to do NO transformations and simply dump raw data into my staging area, and then let it be picked up by dbt or whatever to unravel. Because sometimes, you get broken nested data upstream, or 1-2 new additional level of depth, or some required field might be missing and all of these unknowns make the health of your data system depend on an upstream system. If you simply dump raw data and then unravel in a second step, it's inside your systems scope and easier to control IMHO.