pentaho/pentaho-kettle · error · KettleValueException

Function ATAN only works with numeric data

Error message

Function ATAN only works with numeric data

What it means

The atan() method of Kettle's legacy Value class computes the arc tangent of the value. It requires a numeric Value; if isNumeric() returns false it throws this KettleValueException because Math.atan needs a double. The legacy Value API checks types at runtime rather than at compile time.

Solutions

  1. Convert the Value to Number before calling atan() (setType(VALUE_TYPE_NUMBER) or conversion in the stream)
  2. Ensure the source step produces a Number-typed field
  3. Check isNumeric() before the call and branch accordingly

Example fix

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

Strategy: type-guard

Validate before calling

if (value == null || !value.isNumeric()) {
  throw new IllegalArgumentException("ATAN 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.atan();
} catch (KettleValueException e) {
  value.setType(Value.VALUE_TYPE_NUMBER);
  result = value.atan();
}

Prevention

When it happens

Trigger: Calling Value.atan() on a Value typed as String, Date, Boolean or other non-numeric type - commonly a raw text field passed directly into the trigonometric function.

Common situations: Calculations in Formula/JavaScript steps on fields from delimited-file inputs typed as String; missing 'Select values' type conversion between input and calculation steps.

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

Appendix: source

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

    if ( isNumeric() ) {
      setValue( Math.asin( getNumber() ) );
    } else {
      throw new KettleValueException( "Function ASIN only works with numeric data" );
    }
    return this;
  }

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

    if ( isNumeric() ) {
      setValue( Math.atan( getNumber() ) );
    } else {
      throw new KettleValueException( "Function ATAN only works with numeric data" );
    }
    return this;
  }

  // implement the ATAN2 function, arguments in args[]
  public Value atan2( Value arg0 ) throws KettleValueException {
    return atan2( arg0.getNumber() );
  }

  public Value atan2( double arg0 ) throws KettleValueException {
    if ( isNull() ) {
      return this;
    }

    if ( isNumeric() ) {
      setValue( Math.atan2( getNumber(), arg0 ) );
    } else {
      throw new KettleValueException( "Function ATAN2 only works with numbers" );

View on GitHub (pinned to f3058517a1)