On 2018-02-10 16:13:04 +0100, Nicolas Paris wrote:
> Hello
>
> I d'found useful to be able to import/export from postgres to those modern data
> formats:
> - avro (c writer=https://avro.apache.org/docs/1.8.2/api/c/index.html)
> - parquet (c++ writer=https://github.com/apache/parquet-cpp)
> - orc (all writers=https://github.com/apache/orc)
>
> Something like :
> COPY table TO STDOUT ORC;
>
> Would be lovely.
>
> This would greatly enhance how postgres integrates in big-data ecosystem.
>
> Any thought ?
So, I think making COPY extensible would be quite beneficial. I'm
however quite doubtful that we want to add core code to handle all of
the above. I think we should make the COPY input/output formatting
extensible by extensions. I think we'd have something like
CREATE COPY HANDLER name HANDLER somefunction;
somefunction would have to be a function that returns type
pg_copy_handler, which in turn basically is a struct of function
pointers.
I imagine we'd have callbacks for
- start copy in / out
- output row, with a an array of values/nulls
- parse row, with a input buffer as argument, returning values / nulls arrays
- finish copy in / out
we'd also need to expose a few more utility functions from copy.c
externally.
I think this'd require a good bit of cleanup in copy.c...
Greetings,
Andres Freund