CSV文件输入与Pentaho Kettle

时间:2015-09-23 11:13:06

标签: pentaho kettle

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

您可以在此处查看步骤和配置:

Configuration.

您也可以从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]

进一步说明:

  • 如果我通过使用较低的跳跃来绕过设置的字段值步骤,则转换完成而没有错误。这使我相信它是导致问题的设定字段值步骤。
  • 如果我用相同数据(1,2,3)替换带有数据框的CSV文件输入,一切正常。
  • 如果我用虚拟替换文件输出步骤,转换完成没有错误。但是,如果我预览虚拟对象,则会导致类似的错误,并且字段Y在所有三行上都具有值<null>
  • 在我创建这个MCVE之前,即使没有文件输出,我也会在各种看似随机的步骤中得到错误。所以我认为这与文件输出无关。
  • 如果我将格式从Number更改为Integer,则不会发生任何变化。但是,如果我将其更改为字符串,转换完成没有错误,我得到此输出:

    X;Y
    1;[B@49e96951
    2;[B@7b016abf
    3;[B@1a0760b0
    

这是一个错误吗?难道我做错了什么?我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

这是因为懒惰的转换。把它关掉。这与设计完全一致 - 尽管可以肯定的是,错误和用户体验可以得到改善。

当您需要访问转换中的字段值时,不得使用延迟转换。这正是所做的。默认应该是关闭而不是开启。

如果您的字段直接转到数据库,那么使用它会更快。

你甚至可以使用“部分懒惰”的流,你可以使用延迟转换来获得速度,但是然后使用选择值步骤来“取消lazify”你想要访问的字段,而其余的仍然是懒惰的。

Cunning呵呵?