Spoon Kettle 不能正确管理 NULL 值

Spoon Kettle doesn't manage NULL values correctly

我正在使用 Spoon Kettle PDI 将数据从 csv 文件插入到 MariaDb 数据库。

我正在做一些非常简单的事情,但显然,当 csv 中有 NULL 值时,PDI 将其解释为字符串,这会在最终查询中产生问题:

018/04/25 14:31:23 - Workstation.0 - ERROR (version 7.1.0.0-12, build 1 from 2017-05-16 17.18.02 by buildguy) : Because of an error, this step can't continue:
2018/04/25 14:31:23 - Workstation.0 - ERROR (version 7.1.0.0-12, build 1 from 2017-05-16 17.18.02 by buildguy) : org.pentaho.di.core.exception.KettleValueException: 
2018/04/25 14:31:23 - Workstation.0 - Unexpected conversion error while converting value [checkPoint_id String] to an Integer
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 - checkPoint_id String : couldn't convert String to Integer
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 - checkPoint_id String : couldn't convert String to number : non-numeric character found at position 1 for value [NULL]
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.getInteger(ValueMetaBase.java:2081)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.convertData(ValueMetaBase.java:3785)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.convertBinaryStringToNativeType(ValueMetaBase.java:1579)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.getString(ValueMetaBase.java:1799)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.RowMeta.getString(RowMeta.java:319)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.RowMeta.getString(RowMeta.java:828)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.trans.steps.tableoutput.TableOutput.writeToTable(TableOutput.java:385)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.trans.steps.tableoutput.TableOutput.processRow(TableOutput.java:125)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2018/04/25 14:31:23 - Workstation.0 -   at java.lang.Thread.run(Thread.java:748)
2018/04/25 14:31:23 - Workstation.0 - Caused by: org.pentaho.di.core.exception.KettleValueException: 
2018/04/25 14:31:23 - Workstation.0 - checkPoint_id String : couldn't convert String to Integer
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 - checkPoint_id String : couldn't convert String to number : non-numeric character found at position 1 for value [NULL]
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.convertStringToInteger(ValueMetaBase.java:1323)
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.getInteger(ValueMetaBase.java:2019)
2018/04/25 14:31:23 - Workstation.0 -   ... 9 more
2018/04/25 14:31:23 - Workstation.0 - Caused by: org.pentaho.di.core.exception.KettleValueException: 
2018/04/25 14:31:23 - Workstation.0 - checkPoint_id String : couldn't convert String to number : non-numeric character found at position 1 for value [NULL]
2018/04/25 14:31:23 - Workstation.0 - 
2018/04/25 14:31:23 - Workstation.0 -   at org.pentaho.di.core.row.value.ValueMetaBase.convertStringToInteger(ValueMetaBase.java:1317)
2018/04/25 14:31:23 - Workstation.0 -   ... 10 more

在图像中您可以看到从 csv 导入。我必须指定每一列的类型。异常与列 checkPoint_id 有关,它是一个数字但可以为空。

有没有办法克服这个问题?这似乎是一个非常基本的操作,但我没有看到任何可以打开的选项来修复此行为。

取消选中 Lasy 转换。

如果问题仍然存在,则 CSV 中没有空值标准,很可能在您的情况下,它使用 "null"(字符串)。

如果一次性使用,请在编辑器中打开 CSV 文件并进行全局搜索并将 "null" 替换为“”。

如果您必须自动化或有很多 CSV 文件,请将所有字段读取为字符串;然后使用 Null if... 步骤将 "null" 转换为 NULL;然后在 Metadata 选项卡上使用 Select value 步骤更改数据类型。