pentaho/pentaho-kettle · error · KettleValueException
Function CEIL only works with a number
Error message
Function CEIL only works with a number
What it means
The ceil() method of Kettle's legacy Value class rounds the value up to the nearest integer using Math.ceil. It throws this KettleValueException when the Value is not numeric, since Math.ceil accepts only a double. The legacy Value class enforces operand types at runtime.
Solutions
- Convert the Value to a numeric type before calling ceil()
- Correct the producing step so the field is Number-typed
- Check isNumeric() first and convert or handle non-numeric values explicitly
Example fix
// before
Value rounded = value.ceil(); // value is a String
// after
if (!value.isNumeric()) {
value.setType(Value.VALUE_TYPE_NUMBER);
}
Value rounded = value.ceil(); Defensive patterns
Strategy: type-guard
Validate before calling
if (value == null || !value.isNumeric()) {
throw new IllegalArgumentException("CEIL 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.ceil();
} catch (KettleValueException e) {
value.setType(Value.VALUE_TYPE_NUMBER);
result = value.ceil();
} Prevention
- Round only fields confirmed numeric by the input step
- Convert price/quantity columns parsed from text to Number first
- Call isNumeric() before rounding functions
- Watch for Boolean flags accidentally wired into rounding logic
When it happens
Trigger: Calling Value.ceil() on a Value of type String, Date, or Boolean - e.g. rounding a value that arrived from a text input without numeric conversion.
Common situations: Rounding price/quantity fields parsed from CSV as String; Boolean or flag fields accidentally passed into rounding logic; schema drift after changing an input file format.
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
- Function ACOS only works with numeric data
- Function ASIN only works with numeric data
- Function ATAN only works with numeric data
- Function ATAN2 only works with numbers
- Function COS only works with a number
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/affc92d4820ee27a.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:2442
if ( isNumeric() ) {
setValue( Math.atan2( getNumber(), arg0 ) );
} else {
throw new KettleValueException( "Function ATAN2 only works with numbers" );
}
return this;
}
// implement the CEIL function, arguments in args[]
public Value ceil() throws KettleValueException {
if ( isNull() ) {
return this;
}
if ( isNumeric() ) {
setValue( Math.ceil( getNumber() ) );
} else {
throw new KettleValueException( "Function CEIL only works with a number" );
}
return this;
}
// implement the COS function, arguments in args[]
public Value cos() throws KettleValueException {
if ( isNull() ) {
return this;
}
if ( isNumeric() ) {
setValue( Math.cos( getNumber() ) );
} else {
throw new KettleValueException( "Function COS only works with a number" );
}
return this;
}
View on GitHub (pinned to f3058517a1)