{"record":{"id":"df7f9c12f1f14104","repo":"pentaho/pentaho-kettle","slug":"could-not-find-field","errorCode":null,"errorMessage":"Could not find field ","messagePattern":"Could not find field ","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/gp-bulk-loader/core/src/main/java/org/pentaho/di/trans/steps/gpbulkloader/GPBulkDataOutput.java","lineNumber":119,"sourceCode":"    StringBuffer buf = new StringBuffer( orig );\n\n    Const.repl( buf, enclosure, enclosure + enclosure );\n    return buf.toString();\n  }\n\n  public void writeLine( RowMetaInterface mi, Object[] row ) throws KettleException {\n    if ( first ) {\n      first = false;\n\n      enclosure = meta.getEnclosure();\n\n      // Setup up the fields we need to take for each of the rows\n      // as this speeds up processing.\n      fieldNumbers = new int[meta.getFieldStream().length];\n      for ( int i = 0; i < fieldNumbers.length; i++ ) {\n        fieldNumbers[i] = mi.indexOfValue( meta.getFieldStream()[i] );\n        if ( fieldNumbers[i] < 0 ) {\n          throw new KettleException( \"Could not find field \" + meta.getFieldStream()[i] + \" in stream\" );\n        }\n      }\n\n      sdfDate = new SimpleDateFormat( \"yyyy-MM-dd\" );\n      sdfDateTime = new SimpleDateFormat( \"yyyy-MM-dd HH:mm:ss.SSS\" );\n    }\n\n    // Write the data to the output\n    ValueMetaInterface v = null;\n    int number = 0;\n    for ( int i = 0; i < fieldNumbers.length; i++ ) {\n      if ( i != 0 ) {\n        output.print( \",\" );\n      }\n      number = fieldNumbers[i];\n      v = mi.getValueMeta( number );\n      if ( row[number] == null ) {\n        // TODO (SB): special check for null in case of Strings.","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/gp-bulk-loader/core/src/main/java/org/pentaho/di/trans/steps/gpbulkloader/GPBulkDataOutput.java#L101-L137","documentation":"GPBulkDataOutput.writeLine throws a KettleException 'Could not find field <name> in stream' when a field configured in the bulk loader step's field mapping cannot be located in the incoming row (RowMetaInterface.indexOfValue returns -1). Thrown during first-row setup of fieldNumbers so subsequent writes are fast.","triggerScenarios":"The first row arrives at the step and one of meta.getFieldStream() names is absent from the row's RowMeta — the upstream step was renamed/removed, field order/naming changed, or the step dialog mapping is stale.","commonSituations":"Renaming a field in an upstream Text File Input or Table Input step without updating the GP Bulk Loader mapping; removing a computed field; running a transformation edited in a different version where the mapping was not persisted.","solutions":["Open the GP Bulk Loader step dialog and re-map the Fields table to the actual upstream fields (Get Fields).","Verify the upstream step emits the field name exactly (case-sensitive) as configured.","Insert a Select Values step to add/rename the missing field before the bulk loader.","Re-check hop connections after refactoring upstream steps."],"exampleFix":"// before: upstream renamed 'amount' to 'total_amount' but loader expects 'amount'\nfieldStream = { \"amount\", \"id\" };\n\n// after: update the mapping in the step dialog\nfieldStream = { \"total_amount\", \"id\" }; // matches upstream row","handlingStrategy":"validation","validationCode":"// before running, verify every configured field exists in the row\nRowMetaInterface prev = transMeta.getPrevStepFields( stepName );\nfor ( String name : meta.getFieldStream() ) {\n  if ( prev.indexOfValue( name ) < 0 ) {\n    throw new KettleException( \"Field not in stream: \" + name );\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-run 'Get Fields' after any upstream step change","Keep field names case-consistent across steps","Use a Select Values step to pin field names before bulk loading"],"tags":["stream-fields","mapping","greenplum"],"backgroundTag":"resource-not-found","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"}