CSV 文件输入不能与 Pentaho Kettle 中的设置字段值步骤一起使用

CSV file input not working together with set field value step in Pentaho Kettle

我有一个非常简单的 Pentaho Kettle 转换导致了一个奇怪的错误。它包括从 CSV 中读取一个字段 X,添加一个字段 Y,设置 Y=X,最后将其写回另一个 CSV。

在这里您可以看到它们的步骤和配置:

您也可以从 here 下载 ktr 文件。输入数据就是这样:

1
2
3

当我运行这个转换时,我得到这个错误信息:

ERROR (version 5.4.0.1-130, build 1 from 2015-06-14_12-34-55 by buildguy) : Unexpected error
ERROR (version 5.4.0.1-130, build 1 from 2015-06-14_12-34-55 by buildguy) : org.pentaho.di.core.exception.KettleStepException:
Error writing line

Error writing field content to file

Y Number : There was a data type error: the data type of [B object [[B©b4136a] does not correspond to value meta [Number]



at org.pentaho.di.trans.steps.textfiIeoutput.TextFiIeOutput.writeRowToFile(TextFiIeOutput.java:273)
at org.pentaho.di.trans.steps.textfiIeoutput.TextFileOutput.processRow(TextFiIeOutput.java:195)
at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
atjava.Iang.Thread.run(Unknown Source)
Caused by: org.pentaho.di.core.exception.KettleStepException:
Error writing field content to file

Y Number : There was a data type error: the data type of [B object [[B©b4136a] does not correspond to value meta [Number]


at org.pentaho.di.trans.steps.textfiIeoutput.TextFiIeOutput.writeField(TextFileOutput.java:435)
at org.pentaho.di.trans.steps.textfiIeoutput.TextFiIeOutput.writeRowToFile(TextFiIeOutput.java:249)
3 more
Caused by: org.pentaho.di.core.exception.KettleVaIueException:
Y Number : There was a data type error: the data type of [B object [[B©b4136a] does not correspond to value meta [Number]

at org.pentaho.di.core.row.vaIue.VaIueMetaBase.getBinaryString(VaIueMetaBase.java:2185)
at org.pentaho.di.trans.steps.textfiIeoutput.TextFiIeOutput.formatField(TextFiIeOutput.java:290)
at org.pentaho.di.trans.steps.textfiIeoutput.TextFiIeOutput.writeField(TextFileOutput.java:392)
4 more

以上所有行都以 2015/09/23 12:51:18 - Text file output.0 - 开头,但为了简洁起见,我将其删除。我认为错误消息的相关且令人困惑的部分是:

Y Number : There was a data type error: the data type of [B object [[B©b4136a] does not correspond to value meta [Number]

一些进一步的说明:

这是一个错误吗?难道我做错了什么?我怎样才能使这项工作?

这是因为惰性转换。把它关掉。这完全符合设计 - 尽管错误和用户体验可以得到改善。

当您需要在转换中访问字段值时,不得使用惰性转换。这正是它 所做的 。默认值可能应该关闭而不是打开。

如果你的字段直接进入数据库,那么使用它会更快。

您甚至可以拥有 "partially lazy" 流,其中您使用惰性转换来提高速度,然后使用 select 值步骤来 "un-lazify" 您想要访问的字段,同时剩下的人保持懒惰。

狡猾吧?