cancel
Showing results for 
Search instead for 
Did you mean: 

Loading jsonb postgres data

anayak
New Contributor III

How can I load JSONB data using Postgres snaps? I’m able to load the data as TEXT type but not as JSONB type.
Below is how I’m setting up my pipeline for inserting data to postgres db: image

Any answers would be appreciated!

1 ACCEPTED SOLUTION

anayak
New Contributor III

Never mind, was able to resolve by casting to jsonb using the execute snap. Thanks!

View solution in original post

4 REPLIES 4

pmanchevski
New Contributor II

Hi @anayak

If you are able to load it as TEXT easiest fix would be in the mapper to use JSON.stringify(value) function. This function will convert your value into JSON string.

Also you can try to insert your records with “PostgreSQL - Bulk Load” or with “PostgreSQL - Execute” snaps.

Regards,
Pero Manchevski

anayak
New Contributor III

I have tried JSON.stringify and Json.parse, the value is converted to JSON but not read as jsonb when run with Postgres-Insert snap. Will try bulk load and execute snaps instead. Thanks!

anayak
New Contributor III

@pmanchevski When I use Bulk Load, the auto-increment process_id column can’t be left empty but it does allow loading jsonb data. If I use Insert snap, then JSON.stringify() does make a json string but Inser Snap reads it implicitly as varchar/text and I have no way to typecast in the Insert Snap.
Also, as the data is coming from an excel file where $(all of the excel file data) is used in a column in the table, I’m not sure how to load the data as JSONB using the execute or insert snap.

Here’s the mapper fields:
image

followed by Insert:
image

anayak
New Contributor III

Never mind, was able to resolve by casting to jsonb using the execute snap. Thanks!