Jens Christian Hillerup
08/06/2024, 12:55 PM{
"header": "just-a-plain-old-string",
"sections": [
{"name": "another string", "questions": [ .... ]},
{"name": "another string 2", "questions": [ .... ]},
{"name": "another string 3", "questions": [ .... ]},
{"name": "another string 4", "questions": [ .... ]},
]
}
... you get the gist...
What I end up with in my warehouse is just this string:
{"\"header\"","\"text\"","\"sections\""}
So that's the two roots in the object, header
and sections
and ... I don't know where text
comes from. Also there's some quotation mark business that needs my attention. Digging into it, it kinda looks like I'm out of luck w.r.t. having the JSON Postgres data type supported in the target, and I suppose I could live with a string. But I'd kinda just expect the JSON to survive in a string field. But maybe the problems start already at the tap?Charles Feduke
08/06/2024, 1:34 PMjsonb[]
even though the tap column was jsonb
and ending up in a similar situation where I just had root-level attribute names with no associated JSON hashes. The fix was in target-postgres
where jsonb
became the chosen default via a code change. What target are you using? (It’d be weird if the behavior of your target and target-postgres is exactly the same, because I believe it was the conversion during INSERT
from jsonb
to jsonb[]
where data was lost.)Jens Christian Hillerup
08/06/2024, 1:34 PMJens Christian Hillerup
08/06/2024, 1:35 PMyml
file....Charles Feduke
08/06/2024, 1:36 PMjsonb
was chosen over jsonb[]
Charles Feduke
08/06/2024, 1:36 PMJens Christian Hillerup
08/06/2024, 1:36 PMCharles Feduke
08/06/2024, 1:36 PM- name: target-postgres
variant: meltanolabs
pip_url: meltanolabs-target-postgres~=0.0.14
Charles Feduke
08/06/2024, 1:37 PMJens Christian Hillerup
08/06/2024, 1:37 PMCharles Feduke
08/06/2024, 1:38 PMCharles Feduke
08/06/2024, 1:40 PMjsonb[]
columns still hanging around - note, my version produces a bunch of alter table statements so I could just correct staging and move on:
SELECT
distinct
'alter table ' || c.table_schema || '.' || c.table_name || ' alter column ' || c.column_name || ' type jsonb using to_jsonb(' || c.column_name || ');' as ddl
FROM
information_schema.columns c
JOIN
pg_catalog.pg_class t ON c.table_name = t.relname
JOIN
pg_catalog.pg_attribute a ON a.attname = c.column_name AND a.attrelid = t.oid
JOIN
pg_catalog.pg_type tp ON a.atttypid = tp.oid
WHERE
c.data_type = 'ARRAY' AND tp.typname = '_jsonb';
Jens Christian Hillerup
08/06/2024, 1:43 PMJens Christian Hillerup
08/06/2024, 9:50 PM