{"record":{"id":"6a28970a490f3495","repo":"pentaho/pentaho-kettle","slug":"execsqlrow-exception-couldnotfindfield","errorCode":null,"errorMessage":"ExecSQLRow.Exception.CouldnotFindField","messagePattern":"ExecSQLRow\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/execsqlrow/ExecSQLRow.java","lineNumber":111,"sourceCode":"    if ( first ) { // we just got started\n\n      first = false;\n\n      data.outputRowMeta = getInputRowMeta().clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n        metaStore );\n\n      // Check is SQL field is provided\n      if ( Utils.isEmpty( meta.getSqlFieldName() ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"ExecSQLRow.Error.SQLFieldFieldMissing\" ) );\n      }\n\n      // cache the position of the field\n      if ( data.indexOfSQLFieldname < 0 ) {\n        data.indexOfSQLFieldname = this.getInputRowMeta().indexOfValue( meta.getSqlFieldName() );\n        if ( data.indexOfSQLFieldname < 0 ) {\n          // The field is unreachable !\n          throw new KettleException( BaseMessages.getString( PKG, \"ExecSQLRow.Exception.CouldnotFindField\", meta\n            .getSqlFieldName() ) );\n        }\n      }\n\n    }\n\n    // get SQL\n    String sql = getInputRowMeta().getString( row, data.indexOfSQLFieldname );\n\n    try {\n      if ( meta.isSqlFromfile() ) {\n        if ( Utils.isEmpty( sql ) ) {\n          // empty filename\n          throw new KettleException( BaseMessages.getString( PKG, \"ExecSQLRow.Log.EmptySQLFromFile\" ) );\n        }\n        if ( log.isDebug() ) {\n          logDebug( BaseMessages.getString( PKG, \"ExecSQLRow.Log.ExecutingSQLFromFile\", sql ) );\n        }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/execsqlrow/ExecSQLRow.java#L93-L129","documentation":"KettleException thrown by ExecSQLRow.processRow() when the configured SQL field name cannot be found in the input row metadata (indexOfValue returns -1). The message includes the missing field name. The step cannot locate the column that is supposed to contain the SQL to execute.","triggerScenarios":"InputRowMeta.indexOfValue(meta.getSqlFieldName()) returns -1 at runtime because the upstream step doesn't emit a field with exactly that name (case-sensitive match).","commonSituations":"Renamed/deleted the source field upstream; case mismatch ('SQL' vs 'sql'); transformation edited so the field is no longer produced; running an older ktr against a changed stream.","solutions":["Ensure an upstream step outputs a field whose name exactly (case-sensitively) matches the step's 'SQL field name'.","Use a Select values / Rename step to produce a field with the expected name.","Re-run 'Get Fields' in the step dialog after upstream changes and re-save the transformation."],"exampleFix":"// before (field renamed upstream)\nmeta.setSqlFieldName(\"SQLQuery\");\n// after (match actual field or rename it upstream)\nmeta.setSqlFieldName(\"sql_query\"); // or add Select values: rename SQLQuery -> sql_query","handlingStrategy":"validation","validationCode":"String[] fields = inputRowMeta.getFieldNames();\nif (java.util.Arrays.stream(fields).noneMatch(f -> f.equals(meta.getSqlFieldName()))) {\n  throw new IllegalStateException(\"Field not in stream: \" + meta.getSqlFieldName());\n}","typeGuard":null,"tryCatchPattern":"try { trans.execute(...); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindField\")) { log.error(\"configure matching upstream field\"); } }","preventionTips":["Re-run 'Get fields' after upstream changes","Match field names case-sensitively","Use consistent naming conventions across steps"],"tags":["field-not-found","sql","kettle"],"backgroundTag":"record-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"}