pentaho/pentaho-kettle · error · KettleValueException

The 'ceil' function only works on numeric data

Error message

The 'ceil' function only works on numeric data

What it means

The ceil helper computes the smallest integer >= A, handling Number, Integer, and BigNumber metadata types. Non-numeric types (String, Date, Boolean, etc.) fall through to the default branch and throw this KettleValueException.

Solutions

  1. Type the field as Number/Integer/BigNumber before the Calculator step.
  2. Insert a string-to-number conversion for the field.
  3. Check metaA.getType() in a UDJC step before calling ceil.

Example fix

// before: CEIL(fieldS:String = "3.2") -> throws
// after: Select Values: fieldS Type=Number; then CEIL(fieldS) -> 4
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("ceil(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 {
  c = ValueDataUtil.ceil(metaA, dataA);
} catch (KettleValueException e) {
  logError("ceil on non-numeric field: " + e.getMessage());
  c = null;
}

Prevention

When it happens

Trigger: Calling ValueDataUtil.ceil(metaA, dataA) (Calculator 'CEIL( A )') where metaA.getType() is not TYPE_NUMBER, TYPE_INTEGER, or TYPE_BIGNUMBER — e.g. a String-typed numeric-looking value like "3.2".

Common situations: Numeric values ingested as strings from text/JSON inputs; applying CEIL to a date or boolean field; upstream type changes.

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

Appendix: source

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

    }
    int roundingMode = valueC.intValue();
    return round( metaA, dataA, metaB, dataB, roundingMode );
  }

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

      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" );
    }

View on GitHub (pinned to f3058517a1)