pentaho/pentaho-kettle · error · KettleValueException
Division can only be done with numeric data!
Error message
Division can only be done with numeric data!
What it means
This KettleValueException is thrown by Value.divide() when division is attempted with a non-numeric operand type (Boolean, String, or unhandled default). The compatibility Value class supports division only for Number, Integer, and BigNumber types and rejects all others explicitly to avoid silent misbehavior.
Solutions
- Convert both operands to numeric types before dividing (convertString( VALUE_TYPE_NUMBER ) or new Value with a numeric value).
- Add a Select Values step to force the field type to Number/Integer upstream of the division.
- Check the divisor for zero before dividing to also avoid infinite/NaN results.
- Validate ValueMetaInterface types in the step before performing the operation.
- Catch KettleValueException and report the offending field name and type to the user.
Example fix
// before Value ratio = countValue.divide( strTotal ); // throws: strTotal is STRING // after strTotal.convertString( Value.VALUE_TYPE_BIGNUMBER ); Value ratio = countValue.divide( strTotal );
Defensive patterns
Strategy: type-guard
Validate before calling
// before division if ( !( num.isNumber() || num.isInteger() || num.isBigNumber() ) ) num.convertString( Value.VALUE_TYPE_NUMBER ); if ( den.isBigNumber() && den.getBigNumber().signum() == 0 ) throw new ArithmeticException( "Divide by zero" );
Type guard
boolean isDivisible( Value v ) {
return v != null && ( v.isNumber() || v.isInteger() || v.isBigNumber() );
} Try / catch
try {
Value ratio = a.divide( b );
} catch ( KettleValueException e ) {
throw new IllegalStateException( "Non-numeric operand for divide(): check field types", e );
} Prevention
- Coerce divisor/dividend field types to numeric upstream of division.
- Zero-check divisors before dividing.
- Validate metadata types in the step before operating.
- Convert CSV/text numerics explicitly at ingestion.
- Test transformations with representative field-type metadata.
When it happens
Trigger: value.divide(other) where either operand is VALUE_TYPE_STRING, VALUE_TYPE_BOOLEAN, or another unsupported type — commonly a String field from parsed text used directly as a divisor, or a zero/invalid divisor path guarded only by type checks.
Common situations: CSV/Excel inputs inferred as String; calculator step receiving text fields; upstream steps changed a field's metadata type; forgot type conversion before division in a scripted mapping.
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
- Multiplication can only be done with numbers or a number…
- Subtraction can only be done with numbers!
- The 'divide' function only works on numeric data.
- Function ABS only works with a number
- The 'multiply' function only works on numeric data…
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/4d07e67481576545.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:2282
public Value divide( Value v ) throws KettleValueException {
if ( isNull() || v.isNull() ) {
setNull();
} else {
switch ( getType() ) {
case VALUE_TYPE_BIGNUMBER:
setValue( getBigNumber().divide( v.getBigNumber(), BigDecimal.ROUND_HALF_UP ) );
break;
case VALUE_TYPE_NUMBER:
setValue( getNumber() / v.getNumber() );
break;
case VALUE_TYPE_INTEGER:
setValue( getInteger() / v.getInteger() );
break;
case VALUE_TYPE_BOOLEAN:
case VALUE_TYPE_STRING:
default:
throw new KettleValueException( "Division can only be done with numeric data!" );
}
}
return this;
}
public Value multiply( BigDecimal v ) throws KettleValueException {
return multiply( new Value( "tmp", v ) );
}
public Value multiply( double v ) throws KettleValueException {
return multiply( new Value( "tmp", v ) );
}
public Value multiply( long v ) throws KettleValueException {
return multiply( new Value( "tmp", v ) );
}
public Value multiply( int v ) throws KettleValueException {View on GitHub (pinned to f3058517a1)