{"record":{"id":"24de07981c19c09d","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-field-pgbulkloadermeta","errorCode":null,"errorMessage":"Unable to find field [","messagePattern":"Unable to find field \\[","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"plugins/postgresql-db-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/pgbulkloader/PGBulkLoaderMeta.java","lineNumber":514,"sourceCode":"\n  public SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,\n    Repository repository, IMetaStore metaStore ) throws KettleStepException {\n    SQLStatement retval = new SQLStatement( stepMeta.getName(), databaseMeta, null ); // default: nothing to do!\n\n    if ( databaseMeta != null ) {\n      if ( prev != null && prev.size() > 0 ) {\n        // Copy the row\n        RowMetaInterface tableFields = new RowMeta();\n\n        // Now change the field names\n        for ( int i = 0; i < fieldTable.length; i++ ) {\n          ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );\n          if ( v != null ) {\n            ValueMetaInterface tableField = v.clone();\n            tableField.setName( fieldTable[i] );\n            tableFields.addValueMeta( tableField );\n          } else {\n            throw new KettleStepException( \"Unable to find field [\" + fieldStream[i] + \"] in the input rows\" );\n          }\n        }\n\n        if ( !Utils.isEmpty( tableName ) ) {\n          Database db = new Database( loggingObject, databaseMeta );\n          db.shareVariablesWith( transMeta );\n          try {\n            db.connect();\n\n            String schemaTable =\n              databaseMeta.getQuotedSchemaTableCombination(\n                transMeta.environmentSubstitute( schemaName ), transMeta.environmentSubstitute( tableName ) );\n            String sql = db.getDDL( schemaTable, tableFields, null, false, null, true );\n\n            if ( sql.length() == 0 ) {\n              retval.setSQL( null );\n            } else {\n              retval.setSQL( sql );","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/postgresql-db-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/pgbulkloader/PGBulkLoaderMeta.java#L496-L532","documentation":"In PGBulkLoaderMeta.getSQLStatements(), each stream field name listed in the field mapping (fieldStream[i]) is looked up in the step's incoming row layout via prev.searchValueMeta(fieldStream[i]). If the name is not present in the input rows, a KettleStepException \"Unable to find field [...] in the input rows\" is thrown while generating the CREATE TABLE / SQL preview statements. It means the mapping references a field the upstream step never produces.","triggerScenarios":"getSQLStatements() is called (e.g. from the transformation's SQL button) while fieldStream[i] — a mapped incoming field name — does not match any ValueMeta in the previous step's row output: the field was renamed or removed upstream, the mapping was edited after upstream changes, or the mapping was injected with stale names.","commonSituations":"Renaming a field in a Select Values / Text File Input step without updating the bulk loader mapping; copying a transformation between environments where upstream schemas differ; metadata injection supplying outdated FIELDSTREAM names; typo in the mapped stream field name.","solutions":["Open the PostgreSQL/GP bulk loader's 'Fields' tab and re-select the stream field so it matches the actual upstream field name.","Inspect the previous step's output fields (preview/GET FIELDS) and align the mapping names exactly (case-sensitive).","If upstream changed intentionally, update or delete the stale mapping row; use 'Get fields' to auto-populate the mapping."],"exampleFix":"// before (mapping references old name)\nfieldStream = new String[] { \"cust_nm\" };\n// after: rebuild mapping from actual incoming layout\nRowMetaInterface prev = transMeta.getPrevStepFields( stepMeta );\nfieldStream = new String[] { prev.searchValueMeta( \"customer_name\" ) != null ? \"customer_name\" : ... };","handlingStrategy":"validation","validationCode":"RowMetaInterface prev = transMeta.getPrevStepFields( stepMeta );\nfor ( String f : fieldStream ) {\n  if ( prev.searchValueMeta( f ) == null ) throw new KettleStepException( \"Field not in input rows: \" + f );\n}","typeGuard":null,"tryCatchPattern":"try { sqlStatements = meta.getSQLStatements( transMeta, stepMeta, prev ); } catch ( KettleStepException e ) { /* re-open step dialog, refresh field mapping */ }","preventionTips":["Use 'Get fields' in the step dialog instead of typing names manually.","Re-validate mappings after renaming upstream fields.","Preview the previous step's output before generating SQL."],"tags":["kettle","field-mapping","validation","pentaho"],"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"}