Re: Implicit casts to array types

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: joshua <jzuellig(at)arbormetrix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Implicit casts to array types
Date: 2012-12-14 16:00:50
Message-ID: CAHyXU0yKQ=QCYNPYng2o69W-RXQbJzWXRYHLEV=momjsrBmDWA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Dec 14, 2012 at 9:52 AM, joshua <jzuellig(at)arbormetrix(dot)com> wrote:
> Tom-
> My apologies, I'm still somewhat new to this. Specifically, I'm dealing with
> COPY FROM CSV. I had assumed that since a csv is essentially a pile of text
> and COPY FROM is smart enough to interpret all sorts of csv entries into
> postgresql data types that if I wanted to allow a nonstandard conversion,
> I'd have to define some sort of cast to allow COPY FROM to interpret, say
> ...,green,... as {'green}.
>
> Merlin-
> I could set this up to use a staging table, but honestly, given our systems,
> it'd be easier for me to change all of our source csv's to simply read
> ...,{abc},... instead of ...,abc,... than to change our code base to use a
> series of staging tables (we will be using brackets in the future; this is
> more of a backwards compatibility issue). Especially since it currently
> doesn't have to inspect the target data type of columns we load up, it
> simply allows the COPY FROM command to do all of the interpreting which
> brings me back to my original point. :)

If input csv doesn't match your destination structure, then staging
the input to a temporary work table and processing the transformation
with a query is really the way to go. Hacking casts is about as ugly
as it gets.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Maciek Sakrejda 2012-12-14 16:05:00 Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)
Previous Message dmp 2012-12-14 15:56:48 Re: Fwd: [ADMIN] Confuse about the behaveior of PreparedStatement.executeBatch (jdbc)