{"record":{"id":"58c67b528d80b817","repo":"pentaho/pentaho-kettle","slug":"tableexists-exception-couldnotfindfield","errorCode":null,"errorMessage":"TableExists.Exception.CouldnotFindField","messagePattern":"TableExists\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tableexists/TableExists.java","lineNumber":81,"sourceCode":"        first = false;\n        data.outputRowMeta = getInputRowMeta().clone();\n        meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n          metaStore );\n\n        // Check is tablename field is provided\n        if ( Utils.isEmpty( meta.getDynamicTablenameField() ) ) {\n          logError( BaseMessages.getString( PKG, \"TableExists.Error.TablenameFieldMissing\" ) );\n          throw new KettleException( BaseMessages.getString( PKG, \"TableExists.Error.TablenameFieldMissing\" ) );\n        }\n\n        // cache the position of the field\n        if ( data.indexOfTablename < 0 ) {\n          data.indexOfTablename = getInputRowMeta().indexOfValue( meta.getDynamicTablenameField() );\n          if ( data.indexOfTablename < 0 ) {\n            // The field is unreachable !\n            logError( BaseMessages.getString( PKG, \"TableExists.Exception.CouldnotFindField\" )\n              + \"[\" + meta.getDynamicTablenameField() + \"]\" );\n            throw new KettleException( BaseMessages.getString(\n              PKG, \"TableExists.Exception.CouldnotFindField\", meta.getDynamicTablenameField() ) );\n          }\n        }\n      } // End If first\n\n      // get tablename\n      String tablename = getInputRowMeta().getString( r, data.indexOfTablename );\n\n      // Check if table exists on the specified connection\n      tablexists = data.db.checkTableExists( data.realSchemaname, tablename );\n\n      Object[] outputRowData = RowDataUtil.addValueData( r, getInputRowMeta().size(), tablexists );\n\n      // add new values to the row.\n      putRow( data.outputRowMeta, outputRowData ); // copy row to output rowset(s);\n\n      if ( log.isRowLevel() ) {\n        logRowlevel( BaseMessages.getString( PKG, \"TableExists.LineNumber\", getLinesRead()","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tableexists/TableExists.java#L63-L99","documentation":"TableExists.processRow throws this when the configured dynamic-table-name field cannot be found in the incoming row structure. The field name is set, but indexOfValue() on the input RowMeta returns -1, meaning no such column arrives at the step.","triggerScenarios":"Running the transformation where getInputRowMeta().indexOfValue(meta.getDynamicTablenameField()) returns -1 — upstream step no longer emits the field, field was renamed, or the configured name differs by case/whitespace.","commonSituations":"Renaming or removing an upstream Select values/Text file output field; changing an upstream SQL to drop the column; mismatch between 'Tablename field' and the actual column name; transformations edited after upstream layout changes.","solutions":["Ensure the upstream step actually emits a column matching the configured 'Tablename field' name exactly","Open the step dialog and re-select the field from the updated input layout","Preview the upstream step to confirm the field name and case","Add or fix the upstream step (e.g. Calculator/Select values) that should produce the field"],"exampleFix":"// before: upstream dropped the field\n// SQL: SELECT other_col FROM src\n// after: emit the field the step expects\n// SQL: SELECT tablename, other_col FROM src","handlingStrategy":"validation","validationCode":"// verify the field exists in the incoming layout before running\nTableExistsMeta meta = (TableExistsMeta) stepMeta.getStepMetaInterface();\nRowMetaInterface prev = transMeta.getPrevStepFields(stepMeta);\nif (prev.indexOfValue(meta.getDynamicTablenameField()) < 0) {\n  throw new IllegalStateException(\"Field '\" + meta.getDynamicTablenameField() + \"' not produced by upstream steps\");\n}","typeGuard":null,"tryCatchPattern":"try { trans.execute(null); }\ncatch (KettleException e) {\n  if (e.getMessage().contains(\"CouldnotFindField\")) {\n    logError(\"Re-map the tablename field: upstream layout changed\");\n  }\n}","preventionTips":["Use 'Show input fields' after editing upstream steps to keep mappings current","Avoid renaming fields feeding TableExists; update step dialogs when you do","Preview upstream steps during development to lock down the layout"],"tags":["kettle","field-mapping","row-metadata","step-execution"],"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"}