From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com>, Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com> |
Cc: | Davin Shearer <davin(at)apache(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Emitting JSON to file using COPY TO |
Date: | 2023-12-03 13:46:28 |
Message-ID: | 65fab458-fd9d-1f0c-6d6a-d9726cb43044@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On 2023-12-02 Sa 17:43, Joe Conway wrote:
> On 12/2/23 13:50, Maciek Sakrejda wrote:
>> On Fri, Dec 1, 2023 at 11:32 AM Joe Conway <mail(at)joeconway(dot)com> wrote:
>>> 1. Is supporting JSON array format sufficient, or does it need to
>>> support some other options? How flexible does the support scheme
>>> need to be?
>>
>> "JSON Lines" is a semi-standard format [1] that's basically just
>> newline-separated JSON values. (In fact, this is what
>> log_destination=jsonlog gives you for Postgres logs, no?) It might be
>> worthwhile to support that, too.
>>
>> [1]: https://jsonlines.org/
>
>
> Yes, I have seen examples of that associated with other databases
> (MSSQL and Duckdb at least) as well. It probably makes sense to
> support that format too.
You can do that today, e.g.
copy (select to_json(q) from table_or_query q) to stdout
You can also do it as a single document as proposed here, like this:
copy (select json_agg(q) from table_or_query q) to stdout
The only downside to that is that it has to construct the aggregate,
which could be ugly for large datasets, and that's why I'm not opposed
to this patch.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2023-12-03 14:53:49 | Re: Emitting JSON to file using COPY TO |
Previous Message | Joe Conway | 2023-12-02 22:43:52 | Re: Emitting JSON to file using COPY TO |
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitry Dolgov | 2023-12-03 14:14:44 | Re: Schema variables - new implementation for Postgres 15 |
Previous Message | Haotian Chen | 2023-12-03 13:38:33 | 答复: Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list" |