pentaho/pentaho-kettle · error · KettleStepException

The type of the field

Error message

The type of the field [{0}] is different of the replace value field [{1}]

What it means

Set Value Field performs a raw object copy r[field] = r[replaceBy] with no type conversion, so processRow enforces that both ValueMetaInterface entries have identical Kettle value types. When SourceValue.getType() != ReplaceByValue.getType() it throws KettleStepException listing both fields and their type descriptions (e.g. String vs Number).

Solutions

  1. Insert a 'Select values' step with a Metadata tab entry to convert the source field to the same type as the target before Set Value Field.
  2. Or use 'Value Mapper' / 'Calculator' / 'User Defined Java Expression' to perform the copy with explicit conversion.
  3. Align upstream typing (e.g. set the Text file input field format/type) so both fields share the same Kettle type.
  4. Preview both fields and check their type descriptions in the message to confirm which side to convert.

Example fix

// before: direct copy String -> Number fails
r[idxAmount] = r[idxAmountStr];
// after: convert with Select values (metadata) first
// Select values: amount_str (String) -> amount_num (Number, format #.##)
r[idxAmount] = r[idxAmountNum];
Defensive patterns

Strategy: validation

Validate before calling

ValueMetaInterface source = rowMeta.getValueMeta(rowMeta.indexOfValue(srcField));
ValueMetaInterface target = rowMeta.getValueMeta(rowMeta.indexOfValue(tgtField));
if (source.getType() != target.getType()) {
  throw new IllegalStateException("Type mismatch: " + source.getTypeDesc() + " vs " + target.getTypeDesc());
}

Try / catch

try {
  trans.execute(null);
} catch (KettleStepException e) {
  log.error("Field type mismatch in Set Value Field: {}", e.getMessage());
}

Prevention

When it happens

Trigger: processRow compares getInputRowMeta().getValueMeta(indexOfField[i]).getType() with getValueMeta(indexOfReplaceByValue[i]).getType(); any type difference (String vs Integer, Date vs String, Number vs BigNumber, etc.) between the target field and the replace-by field triggers the throw.

Common situations: Copying a numeric column into a string column; upstream CSV/Text file input typed a column differently than the database field; a variable substitution changed which field is used, silently altering types; transformation edited after upstream type inference changed.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/setvaluefield/SetValueField.java:107

        if ( Utils.isEmpty( sourceField ) ) {
          throw new KettleStepException( BaseMessages.getString(
            PKG, "SetValueField.Log.ReplaceByValueFieldMissing", "" + i ) );
        }
        data.indexOfReplaceByValue[i] = data.outputRowMeta.indexOfValue( sourceField );
        if ( data.indexOfReplaceByValue[i] < 0 ) {
          throw new KettleStepException( BaseMessages.getString(
            PKG, "SetValueField.Log.CouldNotFindFieldInRow", sourceField ) );
        }
        // Compare fields type
        ValueMetaInterface SourceValue = getInputRowMeta().getValueMeta( data.indexOfField[i] );
        ValueMetaInterface ReplaceByValue = getInputRowMeta().getValueMeta( data.indexOfReplaceByValue[i] );

        if ( SourceValue.getType() != ReplaceByValue.getType() ) {
          String err =
            BaseMessages.getString( PKG, "SetValueField.Log.FieldsTypeDifferent", SourceValue.getName()
              + " (" + SourceValue.getTypeDesc() + ")", ReplaceByValue.getName()
              + " (" + ReplaceByValue.getTypeDesc() + ")" );
          throw new KettleStepException( err );
        }
      }
    }
    try {
      for ( int i = 0; i < data.indexOfField.length; i++ ) {
        r[data.indexOfField[i]] = r[data.indexOfReplaceByValue[i]];
      }
      putRow( data.outputRowMeta, r ); // copy row to output rowset(s);
    } catch ( KettleException e ) {
      boolean sendToErrorRow = false;
      String errorMessage = null;

      if ( getStepMeta().isDoingErrorHandling() ) {
        sendToErrorRow = true;
        errorMessage = e.toString();
      } else {
        logError( BaseMessages.getString( PKG, "SetValueField.Log.ErrorInStep", e.getMessage() ) );
        setErrors( 1 );

View on GitHub (pinned to f3058517a1)