MeltanoLabs / target-postgres

MIT License
11 stars 20 forks source link

JSONB field from tap-postgres generated schema is mapped into JSONB[] column #394

Closed hudovisk closed 3 months ago

hudovisk commented 3 months ago

Hello!

I was migrating our pipeline from the transferwise variant into meltanolabs variant of target-postgres and I stumbled on this problem. A generated schema from tap-postgres (meltanolabs variant) for a table with a column of jsonb type is being translated to a jsonb array type in target-postgres.

Here is a sample singer tap output:

{"type":"SCHEMA", "stream":"test_jsonb_data", "key_properties":["id"], "schema":{"required":["id"], "type":"object", "properties":{"id":{"type":["integer"]},"event_data":{"type":["string","number","integer","array","object","boolean","null"]}}}}
{"type":"RECORD","stream":"test_jsonb_data","record":{"id":1,"event_data":null,"time_extracted":"2024-07-27T12:24:43.774995+00:00"}}
{"type":"RECORD","stream":"test_jsonb_data","record":{"id":2,"event_data":{"test":{"test_name":"test_value"}},"time_extracted":"2024-07-27T12:24:43.774995+00:00"}}

Loader config:

loaders:
    - name: target-postgres
      variant: meltanolabs
      pip_url: meltanolabs-target-postgres
      config:
        host: db-warehouse
        user: meltano
        database: data_warehouse

I spent some time debugging it and I think I found the source of the problem. I will create a PR for it but let me know if my assumptions make sense.

Thanks!