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 1rVmrg-001KFf-8J for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Feb 2024 06:17:28 +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 1rVmre-00ADt9-O0 for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Feb 2024 06:17:26 +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 1rVmre-00ADt1-EZ for pgsql-hackers@lists.postgresql.org; Fri, 02 Feb 2024 06:17:26 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rVmrX-004eLl-2v for pgsql-hackers@postgresql.org; Fri, 02 Feb 2024 06:17:25 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTPA id 1AD6C6088B; Fri, 2 Feb 2024 15:17:15 +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=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 02 Feb 2024 15:17:15 +0900 From: torikoshia To: "David G. Johnston" Cc: Pgsql Hackers 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: <4103fc2d86f6024932159d4ad23be0eb@oss.nttdata.com> X-Sender: torikoshia@oss.nttdata.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-01-27 00:20, David G. Johnston wrote: Thanks for your comments! > On Fri, Jan 26, 2024 at 2:49 AM 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? > > I'm opposed to adding this particular feature. > > When implementing this kind of business rule I'd need the option to > specify a percentage, not just an absolute value. Yeah, it seems useful for some cases. Actually, Greenplum enables to specify not only the max number of bad rows but also its percentage[1]. I may be wrong, but considering some dataloaders support something like reject_limit(Redshift supports MAXERROR[2], pg_bulkload supports PARSE_ERRORS[3]), specifying the "number" of the bad row might also be useful. I think we can implement reject_limit specified by percentage simply calculating the ratio of skipped and processed at the end of CopyFrom() like this: if (cstate->opts.reject_limit > 0 && (double) skipped / (processed + skipped) > cstate->opts.reject_limit_percent) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), errmsg("exceeded the ratio specified by .. > I would focus on trying to put the data required to make this kind of > determination into a place where applications implementing such > business rules and monitoring can readily get at it. The "ERRORS TO" > and maybe a corresponding "STATS TO" option where a table can be > specified for the system to place the problematic data and stats about > the copy itself. It'd be nice to have such informative tables, but I believe the benefit of reject_limit is it fails the entire loading when the threshold is exceeded. I imagine when we just have error and stats information tables for COPY, users have to delete the rows when they confirmed too many errors in these tables. [1]https://docs.vmware.com/en/VMware-Greenplum/7/greenplum-database/admin_guide-load-topics-g-handling-load-errors.html [2]https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-load.html [3]https://ossc-db.github.io/pg_bulkload/pg_bulkload.html -- Regards, -- Atsushi Torikoshi NTT DATA Group Corporation