Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAf6s-007dDi-36 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Dec 2023 23:45:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rAf6o-006aiu-5Y for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Dec 2023 23:45:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAf6n-006ail-Rm for pgsql-hackers@lists.postgresql.org; Tue, 05 Dec 2023 23:45:45 +0000 Received: from mxout1-ec2-va.apache.org ([3.227.148.255]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAf6k-00AIWw-Tr for pgsql-hackers@postgresql.org; Tue, 05 Dec 2023 23:45:45 +0000 Received: from mail.apache.org (mailgw-he-de.apache.org [116.203.246.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with ESMTPS id 0D1933FDA3 for ; Tue, 5 Dec 2023 23:45:40 +0000 (UTC) Received: (qmail 2998741 invoked by uid 116); 5 Dec 2023 23:45:40 -0000 Received: from ec2-52-204-25-47.compute-1.amazonaws.com (HELO mailrelay1-ec2-va.apache.org) (52.204.25.47) by apache.org (qpsmtpd/0.94) with ESMTP; Tue, 05 Dec 2023 23:45:40 +0000 Authentication-Results: apache.org; auth=none Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) by mailrelay1-ec2-va.apache.org (ASF Mail Server at mailrelay1-ec2-va.apache.org) with ESMTPSA id E880F3FD69 for ; Tue, 5 Dec 2023 23:45:36 +0000 (UTC) Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-58ceabd7cdeso3777039eaf.3 for ; Tue, 05 Dec 2023 15:45:36 -0800 (PST) X-Gm-Message-State: AOJu0YxqL4um4deLZbm365XYubyIIpl4syguZtsxhpoOBJ9/o8t7jOql mzepCKNCjy74vAwao/vJ9HSKO/ALFSlrfpPBv+k= X-Google-Smtp-Source: AGHT+IEUGptmTfHUuBoiYzca47C4GBlydoCnkwYCd/9DdXwC6vOFnZ1RfbSYSvI9kZcAAvc0JFuWGNZ8Wg4xYVJLxow= X-Received: by 2002:a05:6358:e49b:b0:170:684:66aa with SMTP id by27-20020a056358e49b00b00170068466aamr120578rwb.8.1701819936349; Tue, 05 Dec 2023 15:45:36 -0800 (PST) MIME-Version: 1.0 References: <9c77b6fa-ee88-b2e6-0fa7-4fc81721da35@dunslane.net> <41dcba92-1075-e5e5-cb99-36711abf6cec@dunslane.net> <5c84b70b-ba18-c45d-dbbe-612fa229b2ce@dunslane.net> <398c22f6-4299-4b17-80bf-2f14f4afd592@joeconway.com> <46cc4507-a0d9-4044-b2ce-5a8bca8015c0@joeconway.com> <2554e520-e103-8978-dcb5-807dfeb77402@dunslane.net> <926ff917-8371-40ec-b5e6-ab7b0e09bdc5@joeconway.com> <315b81d4-4b67-7828-0355-3808cd14acd1@dunslane.net> <7a60faf6-e7f1-419d-aee6-10a78ea2fe81@joeconway.com> In-Reply-To: <7a60faf6-e7f1-419d-aee6-10a78ea2fe81@joeconway.com> From: Davin Shearer Date: Tue, 5 Dec 2023 18:45:24 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Emitting JSON to file using COPY TO To: Joe Conway Cc: Andrew Dunstan , PostgreSQL-development Content-Type: multipart/alternative; boundary="000000000000c726ad060bcbd4bd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c726ad060bcbd4bd Content-Type: text/plain; charset="UTF-8" > 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 --000000000000c726ad060bcbd4bd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>= =C2=A0Am I understanding something incorrectly?

No, you've got it.=C2=A0 You already covered the conce= rns there.

> That seems quite absurd, TBH. I know we've cat= ered for some absurdity in
> the CSV code (much of it down to me), so may= be 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 J= SON documents, one per row
> (the LINES case).

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

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

-Dav= in


--000000000000c726ad060bcbd4bd--