{"record":{"id":"05ddf81f81d04ac2","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-table-name-field-in-input-row","errorCode":null,"errorMessage":"Unable to find table name field [] in input row","messagePattern":"Unable to find table name field \\[\\] in input row","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java","lineNumber":176,"sourceCode":"    String tableName = null;\n\n    boolean sendToErrorRow = false;\n    String errorMessage = null;\n    boolean rowIsSafe = false;\n    int[] updateCounts = null;\n    List<Exception> exceptionsList = null;\n    boolean batchProblem = false;\n    Object generatedKey = null;\n\n    if ( meta.isTableNameInField() ) {\n      // Cache the position of the table name field\n      if ( data.indexOfTableNameField < 0 ) {\n        String realTablename = environmentSubstitute( meta.getTableNameField() );\n        data.indexOfTableNameField = rowMeta.indexOfValue( realTablename );\n        if ( data.indexOfTableNameField < 0 ) {\n          String message = \"Unable to find table name field [\" + realTablename + \"] in input row\";\n          logError( message );\n          throw new KettleStepException( message );\n        }\n        if ( !meta.isTableNameInTable() && !meta.specifyFields() ) {\n          data.insertRowMeta.removeValueMeta( data.indexOfTableNameField );\n        }\n      }\n      tableName = rowMeta.getString( r, data.indexOfTableNameField );\n      if ( !meta.isTableNameInTable() && !meta.specifyFields() ) {\n        // If the name of the table should not be inserted itself, remove the table name\n        // from the input row data as well. This forcibly creates a copy of r\n        //\n        insertRowData = RowDataUtil.removeItem( rowMeta.cloneRow( r ), data.indexOfTableNameField );\n      } else {\n        insertRowData = r;\n      }\n    } else if ( meta.isPartitioningEnabled()\n      && ( meta.isPartitioningDaily() || meta.isPartitioningMonthly() )\n      && ( meta.getPartitioningField() != null && meta.getPartitioningField().length() > 0 ) ) {\n      // Initialize some stuff!","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java#L158-L194","documentation":"TableOutput was configured to take the target table name from a field in the incoming row ('table name defined in a field'), but the configured table name field could not be located in the row's metadata. indexOfValue() returns -1 when no field with that name (after environment substitution) exists, and the step refuses to continue because it cannot determine which table to write to. This is a strict fail-fast check before any row is written.","triggerScenarios":"The step metadata specifies a table name field (meta.getTableNameField()) whose name, after environmentSubstitute(), does not match any field in the input row's RowMeta. Occurs on the first row processed by writeToTable.","commonSituations":"Typo in the 'table name field' setting; renaming or deleting the field upstream (Select values, Calculator) before TableOutput; wrong stream connected; environment variable for the field name not set so it resolves to an empty string; case-sensitivity mismatch in field names.","solutions":["Open the TableOutput step dialog and correct the 'Table name field' to exactly match a field in the input stream.","Inspect the incoming row metadata (right-click the hop / View > Fields) and ensure the table name field exists upstream of this step.","If an environment variable is used in the field name, verify it is set in the transformation/run configuration.","Alternatively, switch to a static table name in the step settings if the target table is fixed."],"exampleFix":"// before\nmeta.setTableNameField( \"${TABLE_FIELD}\" ); // env var unset -> field name \"\"\n// after\nmeta.setTableNameField( \"tablename\" ); // matches an actual field in the input row","handlingStrategy":"validation","validationCode":"// Before writing, verify the table name field exists\nint idx = rowMeta.indexOfValue( tableNameFieldName );\nif ( idx < 0 ) {\n  throw new IllegalArgumentException(\n    \"Fix TableOutput config: field '\" + tableNameFieldName + \"' not in input row\" );\n}","typeGuard":"boolean hasField = rowMeta.searchValueMeta( tableNameFieldName ) != null;","tryCatchPattern":"try { step.processRow(); } catch ( KettleStepException e ) {\n  if ( e.getMessage().startsWith( \"Unable to find table name field\" ) ) {\n    // correct step metadata or upstream stream\n  }\n}","preventionTips":["Cross-check the 'Table name field' against the hop's field list after every upstream change","Avoid renaming fields between the source and TableOutput without updating this setting","Prefer static table names when the target table does not vary per row"],"tags":["kettle","table-output","field-not-found","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"}