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 1rAcq3-007SB2-5Z for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Dec 2023 21:20:19 +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 1rAcq0-006HBY-M0 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Dec 2023 21:20:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAcq0-006HBP-CE for pgsql-hackers@lists.postgresql.org; Tue, 05 Dec 2023 21:20:16 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rAcpx-008yeA-If for pgsql-hackers@postgresql.org; Tue, 05 Dec 2023 21:20:15 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-67ad5b37147so10372136d6.2 for ; Tue, 05 Dec 2023 13:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1701811212; x=1702416012; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=pyd7zaCHwIg8GV4L56Jg0CiJzve5OpG01hUQGy7WUKw=; b=LDHDDSJVEnTb93F+O/E97t2k6v0bHjSPYdC6DOe6z9Ym91IQH7hPlhGUEXL7A5c1NX sLnNuyRDJGpkF7EL6Efl5jMYJ4X9pq5ASQs//YHZawXxS5IAIJvnPNI4F+YfVUBIk7OJ AE+UQNyleK7pTDa1+FPvFEyScuhkXQ5s+TslcrvOVm55InzsPoIaxRawsrlOzDbwRol1 ghFbD1XIuav/fDARGAj2PBKkouB3tlRaEehpRD8swbiaRDjxYzXGJJrYKiKnqYcaH3DX 2gf/gFaxfBBxqX5vMH/V2lya20yUfBEN8JWljHkWU3i+eUBkLdDSF3PWrjhbTcI5vxc+ Bx3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701811212; x=1702416012; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pyd7zaCHwIg8GV4L56Jg0CiJzve5OpG01hUQGy7WUKw=; b=oLRBVeTmAUkV2UbZZ6KTXzUeVmoOYSlJMt1dn0MT7ygn7NEDAaeO/lhO87R0+MXH2A ZwWKHaPMKOgLBeGpcYM+WDXQUTvfUl53PwkVMhfxb3ayCKu7OaCPsgf3sy/zBKphz6Qp TFuD0bBYnCvXGiXxt85r2WqSc1x4VCbAwt3xS07BRpg10UcYwTFprxOiU1NchtLYov0I QUVTzGR8WGM9UZLkgp3sw3owAO/5wpZzoLzIuDOSKuzcdz1fQk3qiZkYXGMf0kKqER06 +Z1xCE9BwFqRLK5i9+P8TDyQtZIsRznxDAWat18wQjZKO3LtayRX4fRRPiWgD3qCu3Qk PCGg== X-Gm-Message-State: AOJu0YzMiMKTXeOq2n7tjRWfse2xx3BVp1yFM4e9d/O9B4M4bl/5rj93 s3Gog3la/GQ9oE06LVoVWD0WiA== X-Google-Smtp-Source: AGHT+IGeqZA3R/FCoqAv9s8i6qnbciHtGWRmmud6JcEmW3OCasiaxP3yMeSJxspTwjHZuBQ2PphCSA== X-Received: by 2002:ad4:4521:0:b0:67a:a45b:60ab with SMTP id l1-20020ad44521000000b0067aa45b60abmr1663843qvu.17.1701811212354; Tue, 05 Dec 2023 13:20:12 -0800 (PST) Received: from ?IPV6:2605:a601:91bc:f600::2bb? ([2605:a601:91bc:f600::2bb]) by smtp.googlemail.com with ESMTPSA id kr3-20020a0562142b8300b0067aad395037sm3372829qvb.60.2023.12.05.13.20.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Dec 2023 13:20:11 -0800 (PST) Message-ID: <315b81d4-4b67-7828-0355-3808cd14acd1@dunslane.net> Date: Tue, 5 Dec 2023 16:20:11 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Emitting JSON to file using COPY TO Content-Language: en-US To: Joe Conway , Davin Shearer , PostgreSQL-development 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> From: Andrew Dunstan In-Reply-To: <926ff917-8371-40ec-b5e6-ab7b0e09bdc5@joeconway.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-12-05 Tu 16:09, Joe Conway wrote: > On 12/5/23 16:02, Joe Conway wrote: >> On 12/5/23 15:55, Andrew Dunstan wrote: >>> and in any other case (e.g. LINES) I can't see why you >>> would have them. > > Oh I didn't address this -- I saw examples in the interwebs of MSSQL > server I think [1] which had the non-array with commas import and > export style. It was not that tough to support and the code as written > already does it, so why not? > > [1] > https://learn.microsoft.com/en-us/sql/relational-databases/json/remove-square-brackets-from-json-without-array-wrapper-option?view=sql-server-ver16#example-multiple-row-result > > 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). cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com