简体   繁体   English

Pentaho:无法使用 PostgreSQL Bulk Loader 将布尔值导入表?

[英]Pentaho: Cannot import Boolean Value to table with PostgreSQL Bulk Loader?

I am currently trying to import some data (from a csv file) to a postgreSQL database.我目前正在尝试将一些数据(从 csv 文件)导入 postgreSQL 数据库。 For this, I am using the CSV file input step to import the csv file into Kettle.为此,我使用 CSV 文件输入步骤将 csv 文件导入 Kettle。 Second, I am using the Modified Java Script Value step for altering some values and I am also adding a new column named VALID.其次,我正在使用 Modified Java Script Value 步骤来更改某些值,并且我还添加了一个名为 VALID 的新列。 This column should always be true.此列应始终为真。 I added the column VALID to the fields in the lower half of the step window.我将列 VALID 添加到步骤窗口下半部分的字段中。 My step looks like following:我的步骤如下所示:

在此处输入图片说明

To import the data from kettle to the PostgreSQL database table, I am using the PostgreSQL Bulk Loader (as there are millions of rows to import).要将数据从kettle 导入PostgreSQL 数据库表,我使用了PostgreSQL Bulk Loader(因为要导入数百万行)。 This steps looks like following:此步骤如下所示:

在此处输入图片说明

As you can see in this image, the table column name is valid and the stream field is VALID (which is coming from the Javascript Value step).正如您在此图像中看到的,表列名称有效,流字段为 VALID(来自 Javascript Value 步骤)。 Both boolean.两者都是布尔值。 Should be working.应该工作。 But instead, I am getting the following error message if I run the transformation:但是,如果我运行转换,我会收到以下错误消息:

2018/02/12 14:52:50 - PostgreSQL Bulk Loader.0 - Caused by: 
org.postgresql.util.PSQLException: ERROR: invalid input syntax for type 
boolean: "1.0"
Wobei: COPY adac_test, line 1, column valid: "1.0"

Any suggestions on how to fix this?对于如何解决这个问题,有任何的建议吗?

cast "valid" as string.将“有效”转换为字符串。 In postgres the boolean values are "kind of" strings, not really but boolean values on postgres can be inserted as string:在 postgres 中,布尔值是“某种”字符串,不是真的,但 postgres 上的布尔值可以作为字符串插入:

https://www.postgresql.org/docs/9.6/static/datatype-boolean.html https://www.postgresql.org/docs/9.6/static/datatype-boolean.html

based on this documentation , this should work:基于此文档,这应该有效:

   var VALID = 't';

and select type string instead boolean below the code window并在代码窗口下方选择类型字符串而不是布尔值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM