【问题标题】:CSV file input not working together with set field value step in Pentaho KettleCSV 文件输入不能与 Pentaho Kettle 中的设置字段值步骤一起使用
【发布时间】:2015-09-23 11:13:06
【问题描述】:

我有一个非常简单的 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]

一些进一步的说明:

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

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

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

【问题讨论】:

  • 我刚刚发现的一种解决方法是删除添加常量和设置字段值步骤,而是使用公式步骤,将新字段设置为Y,将公式设置为[x]。跨度>
  • 很高兴知道是什么导致了这个问题。
  • 你试过关闭惰性转换吗?这通常是导致文本文件出现奇怪错误的原因。

标签: pentaho kettle


【解决方案1】:

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

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

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

您甚至可以使用“部分惰性”流,在其中使用惰性转换来提高速度,然后使用选择值步骤来“取消惰性化”您要访问的字段,而其余字段保持惰性。

狡猾吧?

【讨论】:

  • 这么多年过去了,这仍然是个好建议! - 谢谢,我以为我要疯了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-26
  • 1970-01-01
  • 1970-01-01
  • 2021-08-06
相关资源
最近更新 更多