pentaho/pentaho-kettle · error · KettleValueException

Function SIGN only works with a number

Error message

Function SIGN only works with a number

What it means

Thrown by Value.sign() when the value is not numeric. SIGN returns -1, 0, or 1 as an Integer and is only defined for numeric types; the guard throws KettleValueException otherwise. Null values are returned unchanged before the check.

Solutions

  1. Check value.isNumeric() before calling sign().
  2. Re-type the field as Number/Integer in the input or a 'Select values' step.
  3. Convert string data to a number before applying SIGN.
  4. Wrap in try/catch on KettleValueException with an error-handling hop.

Example fix

// before
int s = value.sign().getInteger(); // throws for String-typed value
// after
int s = value.isNumeric() ? value.sign().getInteger() : 0;
Defensive patterns

Strategy: type-guard

Validate before calling

if (!value.isNumeric()) { throw new IllegalArgumentException("SIGN requires a numeric value"); }

Type guard

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

Try / catch

try { int s = value.sign().getInteger(); } catch (KettleValueException e) { s = 0; }

Prevention

When it happens

Trigger: Calling value.sign() on a Value typed as String, Date, Boolean, or Binary.

Common situations: Sign of a field that was ingested as String from a flat file; using SIGN on a Boolean column; metadata mis-typing after a database schema change.

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

Appendix: source

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

      }
    } else if ( isNumber() ) {
      if ( getNumber() > 0 ) {
        value.setNumber( 1.0 );
      } else if ( getNumber() < 0 ) {
        value.setNumber( -1.0 );
      } else {
        value.setNumber( 0.0 );
      }
    } else if ( isInteger() ) {
      if ( getInteger() > 0 ) {
        value.setInteger( 1 );
      } else if ( getInteger() < 0 ) {
        value.setInteger( -1 );
      } else {
        value.setInteger( 0 );
      }
    } else {
      throw new KettleValueException( "Function SIGN only works with a number" );
    }

    return this;
  }

  // implement the SIN function, arguments in args[]
  public Value sin() throws KettleValueException {
    if ( isNull() ) {
      return this;
    }
    if ( isNumeric() ) {
      setValue( Math.sin( getNumber() ) );
    } else {
      throw new KettleValueException( "Function SIN only works with a number" );
    }

    return this;
  }

View on GitHub (pinned to f3058517a1)