json - Pentaho Kettle - 从 JSON 表输出到 Postgresql JSONB 字段

标签 json postgresql pentaho kettle jsonb

如何让 Pentaho Kettle 将 JSON 数据发送到 PostgreSQL JSONB 字段?每当我尝试将 JSON 数据输出到 Postgresql JSONB 字段类型时,我都会收到错误消息。将 JSON 数据发送到 PostgreSQL 文本字段工作正常,但我想在 PostgreSQL 中保持 JSON 格式。

在 Kettle 论坛上发布了这个问题,但没有得到回复。所以我正在尝试这个论坛。

感谢您的意见!

编辑: 当我运行 Pentaho Kettle 转换并且 Postgresql 中的目标字段是 JSONB 类型时,我得到这个错误:

2015/10/29 15:39:32 - Table output 2.0 - Connected to database [test] (commit=1000)
2015/10/29 15:40:43 - Table output 2.0 - ERROR (version 5.4.0.1-130, build 1 from 2015-06-14_12-34-55 by buildguy) : Unexpected batch update error committing the database connection.
2015/10/29 15:40:43 - Table output 2.0 - ERROR (version 5.4.0.1-130, build 1 from 2015-06-14_12-34-55 by buildguy) : org.pentaho.di.core.exception.KettleDatabaseBatchException: 
2015/10/29 15:40:43 - Table output 2.0 - Error updating batch
2015/10/29 15:40:43 - Table output 2.0 - Batch entry 0 INSERT INTO test_raw_dataj (sensor_readings) VALUES ( '{"data":[{"readings":"[[1325404802000,2.8020381927490234],[1325404812000,2.8020381927490234],[1325404822000,2.817678451538086],[1325404832000,2.817678451538086],[1325404842000,2.8333663940429688],[1325404852000,2.8333663940429688]]","id":"59997f"}]}') was aborted.  Call getNextException to see the cause.
2015/10/29 15:40:43 - Table output 2.0 -    at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2743)
2015/10/29 15:40:43 - Table output 2.0 -    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1928)
2015/10/29 15:40:43 - Table output 2.0 -    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:405)
2015/10/29 15:40:43 - Table output 2.0 -    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2892)
2015/10/29 15:40:43 - Table output 2.0 -    at org.pentaho.di.core.database.Database.emptyAndCommit(Database.java:1362)
2015/10/29 15:40:43 - Table output 2.0 -    ... 3 more
2015/10/29 15:40:43 - Table output 2.0 - Finished processing (I=0, O=0, R=1, W=0, U=0, E=1)

但是,运行相同的转换并且 Postgresql 中的目标字段是 TEXT 类型时,一切正常。

最佳答案

我尝试重新创建问题,最后找到了解决方案。
在您的表输出步骤中

  • 转到连接前面的“编辑”按钮
  • 然后选择选项。
  • 给参数值如下

参数 stringtypevalue 未指定

enter image description here

注意:在常规选项卡中,您必须将连接类型选择为 PostgreSQL 并填写必要的设置。

关于json - Pentaho Kettle - 从 JSON 表输出到 Postgresql JSONB 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33422974/

相关文章:

json - 在 perl 中访问 json 结构的值

pentaho - 循环子作业中的文件名(Kettle 作业)

business-intelligence - pentaho BA 服务器和 Bi 服务器

MDX 测量过滤

Python:json.loads 返回以 'u' 为前缀的项目

json - 有没有办法在不创建细粒度对象的情况下使用 Serde 反序列化任意 JSON?

sql - 从 rails 5 获取随机记录,但在顶部保留一条记录(基于某个值)

python - 类不以多态方式加载

django - 如何安装 Django 的 PostGIS?

java - 如何在Android中使用Jackson解析器处理json数组解析