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]
一些进一步的说明:
- 如果我改用较低的跃点绕过设置字段值步骤,则转换完成时不会出现错误。这使我相信是导致问题的设置字段值步骤。
- 如果我用具有相同数据 (
1,2,3
) 的数据框替换 CSV 文件输入,一切正常。
- 如果我用虚拟文件替换文件输出步骤,则转换完成时没有错误。但是,如果我预览虚拟对象,它会导致类似的错误,并且字段
Y
在所有三行上都具有值 <null>
。
- 在我创建这个 MCVE 之前,我在各种看似随机的步骤中遇到了错误,即使没有文件输出。所以我认为这与文件输出无关。
如果我将格式从数字更改为整数,则没有任何变化。但是,如果我将其更改为字符串,则转换无误地完成,并且我得到以下输出:
X;Y
1;[B@49e96951
2;[B@7b016abf
3;[B@1a0760b0
这是一个错误吗?难道我做错了什么?我怎样才能使这项工作?
这是因为惰性转换。把它关掉。这完全符合设计 - 尽管错误和用户体验可以得到改善。
当您需要在转换中访问字段值时,不得使用惰性转换。这正是它 所做的 。默认值可能应该关闭而不是打开。
如果你的字段直接进入数据库,那么使用它会更快。
您甚至可以拥有 "partially lazy" 流,其中您使用惰性转换来提高速度,然后使用 select 值步骤来 "un-lazify" 您想要访问的字段,同时剩下的人保持懒惰。
狡猾吧?
我有一个非常简单的 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]
一些进一步的说明:
- 如果我改用较低的跃点绕过设置字段值步骤,则转换完成时不会出现错误。这使我相信是导致问题的设置字段值步骤。
- 如果我用具有相同数据 (
1,2,3
) 的数据框替换 CSV 文件输入,一切正常。 - 如果我用虚拟文件替换文件输出步骤,则转换完成时没有错误。但是,如果我预览虚拟对象,它会导致类似的错误,并且字段
Y
在所有三行上都具有值<null>
。 - 在我创建这个 MCVE 之前,我在各种看似随机的步骤中遇到了错误,即使没有文件输出。所以我认为这与文件输出无关。
如果我将格式从数字更改为整数,则没有任何变化。但是,如果我将其更改为字符串,则转换无误地完成,并且我得到以下输出:
X;Y 1;[B@49e96951 2;[B@7b016abf 3;[B@1a0760b0
这是一个错误吗?难道我做错了什么?我怎样才能使这项工作?
这是因为惰性转换。把它关掉。这完全符合设计 - 尽管错误和用户体验可以得到改善。
当您需要在转换中访问字段值时,不得使用惰性转换。这正是它 所做的 。默认值可能应该关闭而不是打开。
如果你的字段直接进入数据库,那么使用它会更快。
您甚至可以拥有 "partially lazy" 流,其中您使用惰性转换来提高速度,然后使用 select 值步骤来 "un-lazify" 您想要访问的字段,同时剩下的人保持懒惰。
狡猾吧?