{"record":{"id":"6cc9d1bf2c2455c8","repo":"pentaho/pentaho-kettle","slug":"dynamicsqlrow-exception-fieldnotfound","errorCode":null,"errorMessage":"DynamicSQLRow.Exception.FieldNotFound","messagePattern":"DynamicSQLRow\\.Exception\\.FieldNotFound","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/dynamicsqlrow/DynamicSQLRow.java","lineNumber":230,"sourceCode":"    if ( r == null ) { // no more input to be expected...\n      setOutputDone();\n      return false;\n    }\n    if ( first ) {\n      if ( Utils.isEmpty( meta.getSQLFieldName() ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"DynamicSQLRow.Exception.SQLFieldNameEmpty\" ) );\n      }\n\n      if ( Utils.isEmpty( meta.getSql() ) ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"DynamicSQLRow.Exception.SQLEmpty\" ) );\n      }\n\n      // cache the position of the field\n      if ( data.indexOfSQLField < 0 ) {\n        data.indexOfSQLField = getInputRowMeta().indexOfValue( meta.getSQLFieldName() );\n        if ( data.indexOfSQLField < 0 ) {\n          // The field is unreachable !\n          throw new KettleException( BaseMessages.getString( PKG, \"DynamicSQLRow.Exception.FieldNotFound\", meta\n            .getSQLFieldName() ) );\n        }\n      }\n    }\n    try {\n      lookupValues( getInputRowMeta(), r );\n\n      if ( checkFeedback( getLinesRead() ) ) {\n        if ( log.isDetailed() ) {\n          logDetailed( BaseMessages.getString( PKG, \"DynamicSQLRow.Log.LineNumber\" ) + getLinesRead() );\n        }\n      }\n    } catch ( KettleException e ) {\n      boolean sendToErrorRow = false;\n      String errorMessage = null;\n\n      if ( getStepMeta().isDoingErrorHandling() ) {\n        sendToErrorRow = true;","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/dynamicsqlrow/DynamicSQLRow.java#L212-L248","documentation":"On the first row, DynamicSQLRow.processRow resolves the configured SQL field name to an index in the input row metadata; if the field is absent from the incoming row it throws this KettleException saying the field is unreachable. The step cannot extract the SQL statement from the row without it.","triggerScenarios":"At runtime when getInputRowMeta().indexOfValue(sqlFieldName) returns -1 — the field named in the step settings is not present in the row arriving from the previous step (renamed, removed, or wrong name configured).","commonSituations":"Upstream step renamed or dropped the field; typo in the SQL fieldname setting; inserting a Select values step that removes the field; case-sensitivity differences.","solutions":["Set the 'SQL fieldname' in the step dialog to a field that actually exists upstream","Add/repair the upstream step (e.g. 'Add constants', JavaScript) to produce the SQL text field","Check with a 'Stream lookup'/preview that the field name matches exactly (case included)","Re-save and re-run after upstream changes"],"exampleFix":"// before\nstep configured with sql fieldname 'query' but upstream emits 'sql_text'\n// after\nconfigure sql fieldname = 'sql_text' (matching the upstream field)","handlingStrategy":"validation","validationCode":"// Ensure the configured field exists in the incoming stream:\nString field = meta.getSQLFieldName();\nif (field == null || inputRowMeta.indexOfValue(field) < 0) {\n  throw new IllegalStateException(\"Field '\" + field + \"' not present in input stream\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  lookupValues(inputRowMeta, row);\n} catch (KettleException e) {\n  logError(\"SQL field not found in input: check upstream steps\", e);\n  stopAll(); setErrors(1);\n  return false;\n}","preventionTips":["Preview the previous step and match the field name exactly (case-sensitive)","Avoid renaming/removing the field upstream without updating this step","Keep the SQL-text-producing step adjacent in the flow","Run transformation checks (Hop: verify) before executing"],"tags":["kettle","field-lookup","configuration"],"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"}