Re: Emitting JSON to file using COPY TO

From: Davin Shearer <davin(at)apache(dot)org>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Emitting JSON to file using COPY TO
Date: 2023-12-05 23:45:24
Message-ID: CALvfUkCNS80P2EH8rOJ3uoTZDJX3MEhk8aOD2iVJqLvveG8zNw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> Am I understanding something incorrectly?

No, you've got it. You already covered the concerns there.

> That seems quite absurd, TBH. I know we've catered for some absurdity in
> the CSV code (much of it down to me), so maybe we need to be liberal in
> what we accept here too. IMNSHO, we should produce either a single JSON
> document (the ARRAY case) or a series of JSON documents, one per row
> (the LINES case).

For what it's worth, I agree with Andrew on this. I also agree with COPY
FROM allowing for potentially bogus commas at the end of non-arrays for
interop with other products, but to not do that in COPY TO (unless there is
some real compelling case to do so). Emitting bogus JSON (non-array with
commas) feels wrong and would be nice to not perpetuate that, if possible.

Thanks again for doing this. If I can be of any help, let me know.
If\When this makes it into the production product, I'll be using this
feature for sure.

-Davin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Estevan Rech 2023-12-06 10:45:35 Delete Account
Previous Message Joe Conway 2023-12-05 21:46:50 Re: Emitting JSON to file using COPY TO

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-12-05 23:46:06 Built-in CTYPE provider
Previous Message Tommy Pavlicek 2023-12-05 22:38:08 Re: [PATCH] ltree hash functions