I am using Pentaho Data Integration for numerous projects at work. We predominantly use Postgres for our database's. One of our older tables has two columns that are set to type bit(1) to store 0 for false and 1 for true.
My task is to synchronize a production table with a copy in our development environment. I am reading the data in using Table Input and immediately trying to do an Insert/Update. However, it fails because of the conversion to Boolean by PDI. I updated the query to cast the values to integers to retain the 0 and 1 but when I run it again, my transformation fails because an integer cannot be a bit value.
I have looked for several days trying different things like using the javascript step to convert to a bit but I have not been able to successfully read in a bit type and use the Insert/Update step to store the data. I also do not believe the Insert/Update step has the capabilities of updating the SQL that is being used to define the data type for the column.
The database connection is set up using:
- Connection Type: PostgreSQL
- Access: Native (JDBC)
- Supports the boolean data type: true
- Quote all in database: true
Note: Altering the table to change the datatype is not optional at this point in time. Too many applications currently depend on this table so altering it in this way could cause undesirable affects
Any help would be appreciated. Thank you.
... is not optional at this point in time. Too many applications currently depend on this table so altering it in this way could cause undesirable affects
Have you considered emulating the old behaviour with a VIEW? (easy if the data is only used read-only; harder otherwise) – joopcast(bit_column_name AS signed)
. However, I just tested it with PostgreSQL 9.3 database and PDI 5.4-stable, and no casting is needed, whatsoever. Can you add a partial DDL of both source and target tables, and the PDI version you run? – Yuval Herziger