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 1r0wm0-008Xci-GE for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Nov 2023 04:36:08 +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 1r0wlx-00Aswc-Sp for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Nov 2023 04:36:05 +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 1r0wlx-00AswU-J2 for pgsql-hackers@lists.postgresql.org; Thu, 09 Nov 2023 04:36:05 +0000 Received: from m15.mail.163.com ([45.254.50.219]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r0wls-005TJL-2Y for pgsql-hackers@lists.postgresql.org; Thu, 09 Nov 2023 04:36:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=l+ucrTmv1b+bCimDGHTjw+qoO6iyFx5co0Kw6i2fCFQ=; b=DJwEd05Y1W2Rsc02eeHu9YB0q0nMUa6oMKIixtyEdRWVF/TP/uhcVFp0CjFoT8 /m9410O5AjRC9HkFgK6cEMnjY6qUwzV3AgDsD9l7sD/7CoTYkrwLjHAWEu0qBP5m XOSPeifnq7b37RHIa4ArgzdJoZkeHTREqBdv5/QuMGmzE= Received: from 66ed4ed24c7c (unknown [140.205.118.143]) by zwqz-smtp-mta-g1-1 (Coremail) with SMTP id _____wCnp_meYUxlLEkWAw--.3422S3; Thu, 09 Nov 2023 12:35:43 +0800 (CST) References: <483E1B59-4A80-450B-8685-7CC12762FD5A@anarazel.de> <0DE0602F-CC12-40ED-B259-3AB91FB02C3B@yesql.se> <8ad8492ff9fae3481d87c7aab4e0aed0@oss.nttdata.com> <9a94e684d6528dff74de5959e97032f3@oss.nttdata.com> <8e5c596e47435e3b37b7a751ebcd9569@oss.nttdata.com> <20230322175000.qbdctk7bnmifh5an@awork3.anarazel.de> <16e09747fcfbb21c30e4c1009c416aa4@oss.nttdata.com> <19551e8c2717c24689913083f841ddb5@oss.nttdata.com> <43399b33fe573f0548410893f41f84b6@oss.nttdata.com> <8de9d5e1-2f81-ee2e-ece4-b1a6ede1f285@yandex.ru> <58fa3b63e88ffd0a09273e38aec0661e@oss.nttdat!> <752672.1699474336@sss.pgh.pa.us> User-agent: mu4e 1.10.7; emacs 29.1 From: zhihuifan1213@163.com To: Tom Lane Cc: Daniel Gustafsson , Damir , torikoshia , PostgreSQL Hackers , Andres Freund , anisimow.d@gmail.com, HukuToc@gmail.com, Andrey Lepikhov , Alena Rybakina , pgsql-hackers@lists.postgresql.org Subject: Re: POC PATCH: copy from ... exceptions to: (was Re: VLDB Features) Date: Thu, 09 Nov 2023 12:33:34 +0800 In-reply-to: <752672.1699474336@sss.pgh.pa.us> Message-ID: <878r77mtlt.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain X-CM-TRANSID:_____wCnp_meYUxlLEkWAw--.3422S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7AryrCF13Ar1Uur4xZFW3GFg_yoW8Zr1rpa yIk39YgrnaqFy3Cwn7Aw48Xa4rZrZayF4Utr1Fkr1kAay5GF92yrsxKrWa9FyxKw1DA34Y vFWv9w1DuF9FvaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j0nmiUUUUU= X-Originating-IP: [140.205.118.143] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/xtbBzx8jU1aEAlHwOwABsr List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane writes: > Daniel Gustafsson writes: >>> On 8 Nov 2023, at 19:18, Tom Lane wrote: >>> I think an actually usable feature of this sort would involve >>> copying all the failed lines to some alternate output medium, >>> perhaps a second table with a TEXT column to receive the original >>> data line. (Or maybe an array of text that could receive the >>> broken-down field values?) Maybe we could dump the message info, >>> line number, field name etc into additional columns. > >> I agree that the errors should be easily visible to the user in some way. The >> feature is for sure interesting, especially in data warehouse type jobs where >> dirty data is often ingested. > > I agree it's interesting, but we need to get it right the first time. > > Here is a very straw-man-level sketch of what I think might work. > The option to COPY FROM looks something like > > ERRORS TO other_table_name (item [, item [, ...]]) > > where the "items" are keywords identifying the information item > we will insert into each successive column of the target table. > This design allows the user to decide which items are of use > to them. I envision items like While I'm pretty happy with the overall design, which is 'ERRORS to other_table_name' specially. I'm a bit confused why do we need to write the codes for (item [, item [, ...]]), not only because it requires more coding but also requires user to make more decisions. will it be anything wrong to make all of them as default? > LINENO bigint COPY line number, counting from 1 > LINE text raw text of line (after encoding conversion) > FIELDS text[] separated, de-escaped string fields (the data > that was or would be fed to input functions) > FIELD text name of troublesome field, if field-specific > MESSAGE text error message text > DETAIL text error message detail, if any > SQLSTATE text error SQLSTATE code > -- Best Regards Andy Fan