如果Kettle ETL中不存在文件夹,如何避免失败?

时间:2012-11-30 18:38:30

标签: etl pentaho kettle

使用Pentaho的Kettle工具,我有一个转换设置,从一个Get File Names步骤开始,从目录中获取所有XML文件。该步骤配置如下:

File/Directory: "c:\DataFolder"
Wildcard (RegExp): ".*xml"

这很好用,并且在“DataFolder”文件夹中提供了所有XML文件。

但是,如果DataFolder不存在(因为其他人删除了它),我会收到此错误:

2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) : org.apache.commons.vfs.FileNotFolderException: Could not list the contents of "file:///c:/DataFolder" because it is not a folder.
2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) :  at org.apache.commons.vfs.provider.AbstractFileObject.getChildren(Unknown Source)
2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) :  at org.pentaho.di.core.fileinput.FileInputList.createFileList(FileInputList.java:268)
2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) :  at org.pentaho.di.trans.steps.getfilenames.GetFileNamesMeta.getFileList(GetFileNamesMeta.java:690)
2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) :  at org.pentaho.di.trans.steps.getfilenames.GetFileNames.init(GetFileNames.java:336)
2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) :  at org.pentaho.di.trans.step.StepInitThread.run(StepInitThread.java:62)
2012/11/30 12:15:27 - FileInputList - ERROR (version 4.3.0-stable, build 16786 from 2012-04-24 14.11.32 by buildguy) :  at java.lang.Thread.run(Unknown Source)

或简而言之:FileNotFolderException:无法列出“file:/// c:/ DataFolder”的内容,因为它不是文件夹。

如果文件夹不存在,我想简单地停止转换而不继续。

我尝试使用File Exists步骤结合Filter Rows步骤来提供条件,但没有运气。 Hello World tutorial显示如何检查文件是否存在,但不是整个文件夹。

1 个答案:

答案 0 :(得分:2)

创建父作业,添加此http://wiki.pentaho.com/display/EAI/Check+if+a+folder+is+empty,然后如果FALSE将流程重新加入转换

或者您可以尝试使用创建文件夹步骤作业:http://wiki.pentaho.com/display/EAI/Create+a+folder