pentaho/pentaho-kettle · error · KettleStepException

ExecSQL.Exception.CouldNotFindField

ExecSQL.Exception.CouldNotFindField

Error message

ExecSQL.Exception.CouldNotFindField

What it means

Thrown by ExecSQL.processRow when one of the configured argument field names cannot be found in the incoming row stream. indexOfValue returns -1 for each missing field, which triggers this KettleStepException with the field name from the message bundle. The ExecSQL step needs all argument fields present in the input rows to bind SQL parameters.

Solutions

  1. Open the ExecSQL step and re-map the arguments to existing fields from the incoming stream
  2. Check upstream steps to confirm the field is produced with the exact name (case included)
  3. Add/repair the upstream step that generates the missing field
  4. Preview the input rows to see the actual field names before the ExecSQL step

Example fix

// before (step config)
arguments = new String[] { "custID" };   // input has "custId"
// after
arguments = new String[] { "custId" };   // match exact input field name
Defensive patterns

Strategy: validation

Validate before calling

String[] args = execSqlMeta.getArguments();
RowMetaInterface input = trans.getTransMeta().getPrevStepFields(execSqlStepName);
for (String a : args) {
  if (a != null && input.indexOfValue(a) < 0) {
    throw new IllegalStateException("Argument field not in input stream: " + a);
  }
}

Try / catch

try { trans.execute(null); trans.waitUntilFinished(); } catch (KettleException e) { /* inspect result rows / log for CouldNotFindField and fix mapping */ }

Prevention

When it happens

Trigger: Running a transformation where the ExecSQL step's 'insert field' / arguments list references a field absent from the input row meta — e.g. an upstream step was renamed, removed, or its output field name changed after the ExecSQL step was configured.

Common situations: Renaming a field in a Select values or Text file input step upstream; deleting a Calculator step that produced the argument field; case-sensitive field name mismatch; streaming data from a changed external schema.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/10f150b528d66823. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/sql/ExecSQL.java:121

      setOutputDone();
      return false;
    }

    if ( first ) { // we just got started

      first = false;

      data.outputRowMeta = getInputRowMeta().clone();
      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,
        metaStore );

      // Find the indexes of the arguments
      data.argumentIndexes = new int[meta.getArguments().length];
      for ( int i = 0; i < meta.getArguments().length; i++ ) {
        data.argumentIndexes[i] = this.getInputRowMeta().indexOfValue( meta.getArguments()[i] );
        if ( data.argumentIndexes[i] < 0 ) {
          logError( BaseMessages.getString( PKG, "ExecSQL.Log.ErrorFindingField" ) + meta.getArguments()[i] + "]" );
          throw new KettleStepException( BaseMessages.getString( PKG, "ExecSQL.Exception.CouldNotFindField", meta
            .getArguments()[i] ) );
        }
        if ( meta.isParams() ) {
          if ( i == 0 ) {
            // Define parameters meta
            data.paramsMeta = new RowMeta();
          }
          data.paramsMeta.addValueMeta( getInputRowMeta().getValueMeta( data.argumentIndexes[i] ) );
        }
      }

      if ( !meta.isParams() ) {
        // We need to replace question marks by string value

        // Find the locations of the question marks in the String...
        // We replace the question marks with the values...
        // We ignore quotes etc. to make inserts easier...
        data.markerPositions = new ArrayList<Integer>();

View on GitHub (pinned to f3058517a1)