COPY Transform support - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject COPY Transform support
Date
Msg-id 200804031517.29357.dfontaine@hi-media.com
Whole thread Raw
Responses Re: COPY Transform support  (NikhilS <nikkhils@gmail.com>)
Re: COPY Transform support  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

Here's a proposal for COPY to support the T part of an ETL, that is adding the
capability for COPY FROM to Transform the data it gets.

The idea is quite simple: adding to COPY FROM the option to run a function on
the data before to call datatype_in functions. This needs some syntax
addition to be worked out at the COPY side, then the COPY code will have to
run the given function on the read data and consider giving the output of it
to current COPY code (datatype input function).

The function could either get the data as text or bytea, and would have to
return either text or bytea. bytea seems the more sensible choice, as long as
we don't lose encoding information there, which I'm not sure about.

The syntax could be something like:COPY mytable FROM '/my/file.txt' WITH COLUMN x CONVERT USING myfunc;

I tried to only add keywords already present in [1], while getting something
meaningfull... and x is intended to be the column number, counting from 1.[1]
http://www.postgresql.org/docs/8.3/static/sql-keywords-appendix.html

Comments?
--
dim

pgsql-hackers by date:

Previous
From: "Dawid Kuroczko"
Date:
Subject: Re: psql \G command -- send query and output using extended format
Next
From: "Greg Sabino Mullane"
Date:
Subject: Re: modules