pentaho/pentaho-kettle · error · KettleValueException
Function ACOS only works with numeric data
Error message
Function ACOS only works with numeric data
What it means
In Pentaho Kettle's legacy org.pentaho.di.compatibility.Value class, the acos() method computes the arc cosine of the value. Before doing so it checks isNumeric(); if the Value holds a non-numeric type (string, date, boolean, etc.) it throws this KettleValueException because Math.acos requires a double. The legacy Value class performs these explicit runtime type checks instead of relying on the compiler.
Solutions
- Convert the Value to a number before calling acos(), e.g. value.setType(Value.VALUE_TYPE_NUMBER) or use the appropriate conversion method
- Fix upstream field metadata so the column arrives as Number (Numeric type in Select values / Text file input)
- Guard the call with if (value.isNumeric()) and handle the non-numeric branch explicitly
Example fix
// before
Value result = value.acos();
// after
if (!value.isNumeric()) {
value.setType(Value.VALUE_TYPE_NUMBER); // convert string/other to number
}
Value result = value.acos(); Defensive patterns
Strategy: type-guard
Validate before calling
if (value == null || !value.isNumeric()) {
throw new IllegalArgumentException("ACOS 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.acos();
} catch (KettleValueException e) {
// value was non-numeric: convert and retry or fail the row
value.setType(Value.VALUE_TYPE_NUMBER);
result = value.acos();
} Prevention
- Always declare numeric columns as Number in input steps (Text file input, Excel input, Table input)
- Insert a 'Select values' type-conversion step before mathematical calculations
- Call isNumeric() as a precondition before any legacy Value math function
- Avoid letting intermediate results pass through String fields in calculation chains
When it happens
Trigger: Calling Value.acos() on a Value whose type is not VALUE_TYPE_NUMBER/INTEGER/BIGNUMBER - e.g. a field read from a text file column that stayed a String, or a null-typed Value that was not converted first.
Common situations: JavaScript/formula-like transform steps that call mathematical functions on fields typed as String; CSV/Excel inputs where a numeric column was inferred as String due to formatting characters; migrating old Kettle transformations where Value type conversion steps were removed.
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 ASIN only works with numeric data
- Function ATAN only works with numeric data
- Function ATAN2 only works with numbers
- Function CEIL only works with a number
- Function COS only works with a number
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/350f98d6deb927a1.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:2382
setValue( Math.abs( getNumber() ) );
} else if ( isInteger() ) {
setValue( Math.abs( getInteger() ) );
} else {
throw new KettleValueException( "Function ABS only works with a number" );
}
return this;
}
// implement the ACOS function, arguments in args[]
public Value acos() throws KettleValueException {
if ( isNull() ) {
return this;
}
if ( isNumeric() ) {
setValue( Math.acos( getNumber() ) );
} else {
throw new KettleValueException( "Function ACOS only works with numeric data" );
}
return this;
}
// implement the ASIN function, arguments in args[]
public Value asin() throws KettleValueException {
if ( isNull() ) {
return this;
}
if ( isNumeric() ) {
setValue( Math.asin( getNumber() ) );
} else {
throw new KettleValueException( "Function ASIN only works with numeric data" );
}
return this;
}
View on GitHub (pinned to f3058517a1)