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 1sPCmu-003QT5-Sg for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 03:05: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 1sPCms-00DJyU-QL for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Jul 2024 03:05:35 +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 1sPCms-00DJyG-Gr for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 03:05:35 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPCmq-000Jch-AH for pgsql-hackers@lists.postgresql.org; Thu, 04 Jul 2024 03:05:34 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id 02AD760785; Thu, 4 Jul 2024 12:05:26 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 04 Jul 2024 12:05:25 +0900 From: torikoshia To: Fujii Masao Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Add new COPY option REJECT_LIMIT In-Reply-To: References: <63f99327aa6b404cc951217fa3e61fe4@oss.nttdata.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: torikoshia@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-07-03 02:07, Fujii Masao wrote: Thanks for your comments! > On 2024/01/26 18:49, torikoshia wrote: >> Hi, >> >> 9e2d870 enabled the COPY command to skip soft error, and I think we >> can add another option which specifies the maximum tolerable number of >> soft errors. >> >> I remember this was discussed in [1], and feel it would be useful when >> loading 'dirty' data but there is a limit to how dirty it can be. >> >> Attached a patch for this. >> >> What do you think? > > The patch no longer applies cleanly to HEAD. Could you update it? I'm going to update it after discussing the option format as described below. > > I think the REJECT_LIMIT feature is useful. Allowing it to be set as > either the absolute number of skipped rows or a percentage of the > total input rows is a good idea. > > However, if we support REJECT_LIMIT, I'm not sure if the ON_ERROR > option is still necessary. REJECT_LIMIT seems to cover the same cases. > For instance, REJECT_LIMIT=infinity can act like ON_ERROR=ignore, and > REJECT_LIMIT=0 can act like ON_ERROR=stop. I agree that it's possible to use only REJECT_LIMIT without ON_ERROR. I also think it's easy to understand that REJECT_LIMIT=0 is ON_ERROR=stop. However, expressing REJECT_LIMIT='infinity' needs some definition like "setting REJECT_LIMIT to -1 means 'infinity'", doesn't it? If so, I think this might not so intuitive. Also, since it seems Snowflake and Redshift have both options equivalent to REJECT_LIMIT and ON_ERROR, having both of them in PostgreSQL COPY might not be surprising: - Snowflake's ON_ERROR accepts "CONTINUE | SKIP_FILE | SKIP_FILE_num | 'SKIP_FILE_num%' | ABORT_STATEMENT"[1] - Redshift has MAXERROR and IGNOREALLERRORS options[2] BTW after seeing Snowflake makes SKIP_FILE_num one of the options of ON_ERROR, I'm a bit wondering whether REJECT_LIMIT also should be the same. [1] https://docs.snowflake.com/en/sql-reference/sql/copy-into-table#copy-options-copyoptions [2] https://docs.aws.amazon.com/en_en/redshift/latest/dg/copy-parameters-data-load.html -- Regards, -- Atsushi Torikoshi NTT DATA Group Corporation