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 1r9mns-002GSo-9z for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Dec 2023 13:46:36 +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 1r9mnq-00CSTG-Vv for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Dec 2023 13:46:34 +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 1r9mnq-00CST7-Iw for pgsql-hackers@lists.postgresql.org; Sun, 03 Dec 2023 13:46:34 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r9mnn-008anl-UV for pgsql-hackers@postgresql.org; Sun, 03 Dec 2023 13:46:33 +0000 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-423f4a6144fso27115991cf.0 for ; Sun, 03 Dec 2023 05:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1701611190; x=1702215990; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=fmr4V4KaeHureSrktYOwfbrxnUW83yph40cVe/dlXjE=; b=jDCxa8ulsAQRuwHsKAlHapza0ZGUmSwu9my22liu9TkFsJkPFS3Kto0qSGeMFPSD7R 9H0/JS5tVj4l1TxBCN7D6pCKRmSfY+HUzYKVYuYSqstPky3cb6lG4sd0wFQZRswmNSHT cSXDzHUFULIN5vHEgK4sqwxQlHm4oYKA0o1oTFqpWeFkv8+RG512ZwT32URPw2u7RmBt Dyl2g4F+wDandTqTYgwVoXgiN5WARn1dyabzvT3LYN2tMM1EGszcJ9ab2qSkqr8QgGQd T12X3+eRGEZBXoEeas+n7ik0WslAKrr07JnIpYPS00ghFUdv052Ebb+S3dxF7+LZkCpf 50BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701611190; x=1702215990; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fmr4V4KaeHureSrktYOwfbrxnUW83yph40cVe/dlXjE=; b=jHpvQ0zwKAMhY+6Qd+sxZuAtm12XDoscmdI0v1jXhBA7lGT9grTCTAnkz1JjzBcoSq 8Aj/rD/IFinfqz/rdx+Q/8y3wlaLICap41qtlwk3Y/j0dhiV8+hJnh0s8rTWlVpGR+pP mcDz2Aux+phsVY/M6EVLZC1gDFEir3+V1QRbkqo3JWMFJhpZC4V9YMln0Sd0gcqDhaJi I2gSQSUArUL7BMH0tKvGnD4Oall/J9UOljSesrtLGIkOXheHCqWJClBbdevYPmzqtkmh /KlErlTSnEseWWXhuoh1SpNdBUfzc60HMlSB5vK/3NHAbhnMwUGEjrTFJKCgRjFQ5uSo FFDA== X-Gm-Message-State: AOJu0YwsEofPme1fUzWDbb6uCRsuxyxY7egJtC085yamDCL0vyTpAySA yYYThd84WuKlcQvAgSHbOcyVqGPJIH0FN80yLAw= X-Google-Smtp-Source: AGHT+IFJECV01Vh2rIIhUVc5+tYd/OCEdWtBssQvRVaOH4jXx8TCmw5m3M5pUmNSnXfkATx11mJbsw== X-Received: by 2002:a05:620a:2488:b0:77e:fba3:4f0b with SMTP id i8-20020a05620a248800b0077efba34f0bmr3758272qkn.97.1701611190330; Sun, 03 Dec 2023 05:46:30 -0800 (PST) Received: from ?IPV6:2605:a601:91bc:f600::2bb? ([2605:a601:91bc:f600::2bb]) by smtp.googlemail.com with ESMTPSA id o1-20020a05620a110100b0077dd463da60sm3377404qkk.126.2023.12.03.05.46.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Dec 2023 05:46:29 -0800 (PST) Message-ID: <65fab458-fd9d-1f0c-6d6a-d9726cb43044@dunslane.net> Date: Sun, 3 Dec 2023 08:46:28 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Joe Conway , Maciek Sakrejda Cc: Davin Shearer , PostgreSQL-development References: <3853387.1701096982@sss.pgh.pa.us> <3a98decf-3fe3-4b49-9b68-fda01338872c@sedlakovi.org> <24e3ee88-ec1e-421b-89ae-8a47ee0d2df1@joeconway.com> <70055855-8ea1-43dc-85c2-630b8cf3bbbd@joeconway.com> From: Andrew Dunstan Subject: Re: Emitting JSON to file using COPY TO In-Reply-To: <70055855-8ea1-43dc-85c2-630b8cf3bbbd@joeconway.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 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