pentaho/pentaho-kettle · error · KettleValueException

The 'floor' function only works on numeric data

Error message

The 'floor' function only works on numeric data

What it means

The floor helper computes the largest integer <= A and, like ceil, only supports Number, Integer, and BigNumber metadata types. Any other type reaches the default branch and throws this KettleValueException.

Solutions

  1. Convert the field to a numeric type before the Calculator step.
  2. Fix field metadata (Select Values) so the value is Number/Integer/BigNumber.
  3. Guard with a type check in UDJC/UDJE before calling floor.

Example fix

// before: FLOOR(fieldS:String = "7.9") -> throws
// after: convert fieldS to Number; FLOOR(fieldS) -> 7
Defensive patterns

Strategy: type-guard

Validate before calling

int t = metaA.getType();
if (t != ValueMetaInterface.TYPE_NUMBER && t != ValueMetaInterface.TYPE_INTEGER && t != ValueMetaInterface.TYPE_BIGNUMBER) {
  throw new KettleValueException("floor(A) requires numeric field, got type " + t);
}

Type guard

public static boolean isNumericMeta(ValueMetaInterface m) {
  int t = m.getType();
  return t == ValueMetaInterface.TYPE_NUMBER || t == ValueMetaInterface.TYPE_INTEGER || t == ValueMetaInterface.TYPE_BIGNUMBER;
}

Try / catch

try {
  f = ValueDataUtil.floor(metaA, dataA);
} catch (KettleValueException e) {
  logError("floor on non-numeric field: " + e.getMessage());
  f = null;
}

Prevention

When it happens

Trigger: Calling ValueDataUtil.floor(metaA, dataA) (Calculator 'FLOOR( A )') where metaA.getType() is not numeric (TYPE_NUMBER/TYPE_INTEGER/TYPE_BIGNUMBER), e.g. String "7.9" or a Date field.

Common situations: Flooring a string value from a file input; flooring a timestamp; a field silently re-typed by an upstream step.

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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java:1367

      default:
        throw new KettleValueException( "The 'ceil' function only works on numeric data" );
    }
  }

  public static Object floor( ValueMetaInterface metaA, Object dataA ) throws KettleValueException {
    if ( dataA == null ) {
      return null;
    }
    switch ( metaA.getType() ) {
      case ValueMetaInterface.TYPE_NUMBER:
        return new Double( Math.floor( metaA.getNumber( dataA ).doubleValue() ) );
      case ValueMetaInterface.TYPE_INTEGER:
        return metaA.getInteger( dataA );
      case ValueMetaInterface.TYPE_BIGNUMBER:
        return new BigDecimal( Math.floor( metaA.getNumber( dataA ).doubleValue() ) );

      default:
        throw new KettleValueException( "The 'floor' function only works on numeric data" );
    }
  }

  public static Object abs( ValueMetaInterface metaA, Object dataA ) throws KettleValueException {
    if ( dataA == null ) {
      return null;
    }

    switch ( metaA.getType() ) {
      case ValueMetaInterface.TYPE_NUMBER:
        return new Double( Math.abs( metaA.getNumber( dataA ).doubleValue() ) );
      case ValueMetaInterface.TYPE_INTEGER:
        return metaA.getInteger( Math.abs( metaA.getNumber( dataA ).longValue() ) );
      case ValueMetaInterface.TYPE_BIGNUMBER:
        return metaA.getBigNumber( dataA ).abs();

      default:
        throw new KettleValueException( "The 'abs' function only works on numeric data" );

View on GitHub (pinned to f3058517a1)