{"record":{"id":"73e40a14f1f3f667","repo":"pentaho/pentaho-kettle","slug":"cannot-open-data-file-path-datafile","errorCode":null,"errorMessage":"Cannot open data file [path=${dataFile}]","messagePattern":"Cannot open data file \\[path=(.+?)\\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/terafast-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/terafastbulkloader/TeraFast.java","lineNumber":207,"sourceCode":"          logBasic( BaseMessages.getString( PKG, \"TeraFast.Log.ExitValueFastloadPath\", \"\" + exitVal ) );\n        }\n      } catch ( Exception e ) {\n        logError( BaseMessages.getString( PKG, \"TeraFast.Log.ErrorInStep\" ), e );\n        this.setDefaultError();\n        stopAll();\n      }\n\n      return false;\n    }\n\n    if ( this.first ) {\n      this.first = false;\n      try {\n        final File tempDataFile = new File( resolveFileName( this.meta.getDataFile().getValue() ) );\n        this.dataFile = FileUtils.openOutputStream( tempDataFile );\n        this.dataFilePrintStream = new PrintStream( dataFile );\n      } catch ( IOException e ) {\n        throw new KettleException( \"Cannot open data file [path=\" + this.dataFile + \"]\", e );\n      }\n\n      // determine column sort order according to field mapping\n      // thus the columns in the generated datafile are always in the same order and have the same size as in the\n      // targetTable\n      this.tableRowMeta = this.meta.getRequiredFields( this.getTransMeta() );\n      RowMetaInterface streamRowMeta = this.getTransMeta().getPrevStepFields( this.getStepMeta() );\n      this.columnSortOrder = new ArrayList<>( this.tableRowMeta.size() );\n      for ( int i = 0; i < this.tableRowMeta.size(); i++ ) {\n        ValueMetaInterface column = this.tableRowMeta.getValueMeta( i );\n        int tableIndex = this.meta.getTableFieldList().getValue().indexOf( column.getName() );\n        if ( tableIndex >= 0 ) {\n          String streamField = this.meta.getStreamFieldList().getValue().get( tableIndex );\n          this.columnSortOrder.add( streamRowMeta.indexOfValue( streamField ) );\n        }\n      }\n    }\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/terafast-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/terafastbulkloader/TeraFast.java#L189-L225","documentation":"TeraFast throws this KettleException in processRow (first row) when FileUtils.openOutputStream cannot open the resolved data file for writing; the IOException is chained as the cause. The data file is the intermediate file TeraFast writes row data to before Teradata FastLoad consumes it. If it cannot be created/opened, the bulk load cannot proceed.","triggerScenarios":"First call to processRow() after init: resolveFileName(meta.getDataFile().getValue()) yields a path in a non-existent directory, an unwritable location, a path that is a directory, or the filesystem rejects creation (disk full, permissions).","commonSituations":"Data file path points to a directory that doesn't exist; user running Kettle lacks write permission on the target folder; the path was configured with a variable that resolves to an invalid/empty value; path is on a full or read-only mount; a directory already exists with the same name as the intended file.","solutions":["Verify the Data file property in the TeraFast step resolves to a valid, writable file path (create parent directories, e.g. mkdir -p $(dirname <path>)).","Check filesystem permissions for the user running the transformation (ls -ld on the target directory; chmod/chown as needed).","Confirm all ${VARIABLES} in the data file path resolve correctly at runtime (check the log for the resolved path in the chained cause).","Check disk space and that the mount is not read-only (df -h; touch <path> as the same user).","If the path exists as a directory, remove/rename it or choose a different filename."],"exampleFix":"// before\nthis.dataFile = FileUtils.openOutputStream( new File( this.meta.getDataFile().getValue() ) );\n// after\nFile tempDataFile = new File( resolveFileName( this.meta.getDataFile().getValue() ) );\njava.io.File parent = tempDataFile.getParentFile();\nif ( parent != null && !parent.exists() ) {\n  parent.mkdirs(); // ensure the target directory exists before opening the stream\n}\nthis.dataFile = FileUtils.openOutputStream( tempDataFile );","handlingStrategy":"validation","validationCode":"import java.io.File;\nFile dataFile = new File( resolveFileName( dataFileValue ) );\nFile parent = dataFile.getParentFile();\nif ( parent == null || !parent.isDirectory() || !parent.canWrite() ) {\n  throw new IllegalArgumentException( \"Data file directory missing or unwritable: \" + parent );\n}\nif ( dataFile.isDirectory() ) {\n  throw new IllegalArgumentException( \"Data file path is a directory: \" + dataFile );\n}","typeGuard":"boolean isWritableFilePath( String path ) {\n  File f = new File( path );\n  return f.getParentFile() != null && f.getParentFile().isDirectory()\n    && f.getParentFile().canWrite() && !f.isDirectory();\n}","tryCatchPattern":"try {\n  this.dataFile = FileUtils.openOutputStream( tempDataFile );\n} catch ( IOException e ) {\n  throw new KettleException( \"Cannot open data file [path=\" + tempDataFile.getAbsolutePath()\n    + \"]; check directory exists, permissions, and disk space\", e );\n}","preventionTips":["Create the data file's parent directories in the transformation (or pre-create them at deployment).","Run the transformation under a user with write access to the configured directory.","Use absolute paths or verify all ${variables} resolve before running (test with 'Get Variables' preview).","Monitor disk space on the volume holding the data file."],"tags":["kettle","pdi","teradata","fastload","io","file"],"backgroundTag":"file-open-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}