pentaho/pentaho-kettle · error · KettleValueException

Function EXP only works with a number

Error message

Function EXP only works with a number

What it means

The exp() method of Kettle's legacy Value class raises e to the power of the value using Math.exp. It throws this KettleValueException when the Value is not numeric, since Math.exp requires a double argument. This is the legacy Value class's runtime type contract for math functions.

Solutions

  1. Convert the Value to a numeric type before calling exp()
  2. Ensure upstream steps keep the field typed as Number
  3. Check isNumeric() and handle non-numeric values before the call

Example fix

// before
Value result = value.exp(); // value is a String
// after
if (!value.isNumeric()) {
  value.setType(Value.VALUE_TYPE_NUMBER);
}
Value result = value.exp();
Defensive patterns

Strategy: type-guard

Validate before calling

if (value == null || !value.isNumeric()) {
  throw new IllegalArgumentException("EXP requires a numeric value, got type " + (value == null ? "null" : value.getType()));
}

Type guard

boolean isNumericValue(Value v) { return v != null && v.isNumeric(); }

Try / catch

try {
  result = value.exp();
} catch (KettleValueException e) {
  value.setType(Value.VALUE_TYPE_NUMBER);
  result = value.exp();
}

Prevention

When it happens

Trigger: Calling Value.exp() on a String/Date/Boolean-typed Value, e.g. exponentiating a logarithm value that was serialized back as text.

Common situations: Growth/decay calculations where an intermediate field lost its numeric type; values round-tripped through string fields in old Kettle transformations.

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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:2470

    if ( isNumeric() ) {
      setValue( Math.cos( getNumber() ) );
    } else {
      throw new KettleValueException( "Function COS only works with a number" );
    }
    return this;
  }

  // implement the EXP function, arguments in args[]
  public Value exp() throws KettleValueException {
    if ( isNull() ) {
      return this;
    }

    if ( isNumeric() ) {
      setValue( Math.exp( getNumber() ) );
    } else {
      throw new KettleValueException( "Function EXP only works with a number" );
    }
    return this;
  }

  // implement the FLOOR function, arguments in args[]
  public Value floor() throws KettleValueException {
    if ( isNull() ) {
      return this;
    }

    if ( isNumeric() ) {
      setValue( Math.floor( getNumber() ) );
    } else {
      throw new KettleValueException( "Function FLOOR only works with a number" );
    }
    return this;
  }

View on GitHub (pinned to f3058517a1)