pentaho/pentaho-kettle · error · KettleException

TableCompare.Exception.CanNotFindField

Error message

TableCompare.Exception.CanNotFindField

What it means

TableCompare.processRow looks up the configured reference schema field name in the incoming row layout (getInputRowMeta().indexOfValue). If the field name is configured but not present in the input rows, it throws TableCompare.Exception.CanNotFindField naming the field.

Solutions

  1. Rename the configured 'Reference schema field' to match an actual upstream field exactly (case-sensitive)
  2. Add the field upstream (e.g. via Select values / Calculator) before Table Compare
  3. Preview upstream rows to confirm the field name and ordering
  4. Re-run after fixing the transformation; the step re-resolves indexes per row batch

Example fix

// before
meta.setReferenceSchemaField( "Schema" ); // upstream field is "schema"
// after
meta.setReferenceSchemaField( "schema" ); // matches indexOfValue in input row meta
Defensive patterns

Strategy: validation

Validate before calling

// before executing, confirm the field exists in the upstream row layout
String f = meta.getReferenceSchemaField();
if ( f == null || inputRowMeta.indexOfValue( f ) < 0 ) {
  throw new IllegalArgumentException( "Input stream has no field: " + f );
}

Try / catch

try {
  trans.execute( null );
} catch ( KettleException e ) {
  if ( e.getMessage().contains( "CanNotFindField" ) ) {
    logError( "Field missing in input stream; check upstream steps" );
  }
}

Prevention

When it happens

Trigger: meta.getReferenceSchemaField() is non-empty but indexOfValue returns -1 because upstream steps don't produce a field with that exact name.

Common situations: Renamed or removed upstream field, case-sensitive name mismatch, or the field lives in a different stream than the one connected to the step.

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/3bd411e99baf4ca6. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/tablecompare/TableCompare.java:83

    if ( first ) {
      first = false;

      // What's the format of the output row?
      //
      data.outputRowMeta = getInputRowMeta().clone();
      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,
        metaStore );

      // Reference schema
      //
      if ( Utils.isEmpty( meta.getReferenceSchemaField() ) ) {
        throw new KettleException( BaseMessages.getString(
          PKG, "TableCompare.Exception.ReferenceSchemaNotSpecified" ) );
      }
      data.refSchemaIndex = getInputRowMeta().indexOfValue( meta.getReferenceSchemaField() );
      if ( data.refSchemaIndex < 0 ) {
        throw new KettleException( BaseMessages.getString( PKG, "TableCompare.Exception.CanNotFindField", meta
          .getReferenceSchemaField() ) );
      }

      // Reference table
      //
      if ( Utils.isEmpty( meta.getReferenceTableField() ) ) {
        throw new KettleException( BaseMessages.getString(
          PKG, "TableCompare.Exception.ReferenceTableNotSpecified" ) );
      }
      data.refTableIndex = getInputRowMeta().indexOfValue( meta.getReferenceTableField() );
      if ( data.refTableIndex < 0 ) {
        throw new KettleException( BaseMessages.getString( PKG, "TableCompare.Exception.CanNotFindField", meta
          .getReferenceTableField() ) );
      }

      // Compare schema
      //
      if ( Utils.isEmpty( meta.getCompareSchemaField() ) ) {

View on GitHub (pinned to f3058517a1)