pentaho/pentaho-kettle · error · KettleValueException
Function TRUNC only works on numbers and dates
Error message
Function TRUNC only works on numbers and dates
What it means
Type dispatch guard in the no-argument legacy Value trunc() overload: the value is neither BigNumber, Number nor Date, so there is no truncation semantic to apply and the switch falls through to this sentinel error. The input at fault is the current Value of an unsupported type (e.g. String or Boolean).
Solutions
- Ensure the field passed to TRUNC is a Number, BigNumber or Date
- Convert the value to a numeric or date type before truncating
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3470 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/921369202d6f5944.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3470
return this;
}
if ( isBigNumber() ) {
getBigNumber().setScale( 0, BigDecimal.ROUND_FLOOR );
} else if ( isNumber() ) {
setValue( Math.floor( getNumber() ) );
} else if ( isDate() ) {
Calendar cal = Calendar.getInstance();
cal.setTime( getDate() );
cal.set( Calendar.MILLISECOND, 0 );
cal.set( Calendar.SECOND, 0 );
cal.set( Calendar.MINUTE, 0 );
cal.set( Calendar.HOUR_OF_DAY, 0 );
setValue( cal.getTime() );
} else {
throw new KettleValueException( "Function TRUNC only works on numbers and dates" );
}
return this;
}
// implement the TRUNC function, arguments in args[]
public Value trunc( double level ) throws KettleValueException {
return trunc( (int) level );
}
@SuppressWarnings( { "fallthrough", "squid:S128" } )
public Value trunc( int level ) throws KettleValueException {
if ( isNull() ) {
return this; // don't do anything, leave it at NULL!
}
if ( isInteger() ) {
return this; // nothing to do.View on GitHub (pinned to f3058517a1)