pentaho/pentaho-kettle · error · KettleValueException
Function first_day only works on a date
Error message
Function first_day only works on a date
What it means
Guard in the legacy Value first_day() function: the value's type is not VALUE_TYPE_DATE, so the Calendar that resets the day-of-month to 1 cannot be initialized. The input at fault is the current Value with a non-date type.
Solutions
- Ensure the field passed to first_day is a Date
- Convert the value to a Date before calling FIRST_DAY
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3439 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/c17cbde3fc46fb69.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3439
int last_day = cal.getActualMaximum( Calendar.DAY_OF_MONTH );
cal.set( Calendar.DAY_OF_MONTH, last_day );
setValue( cal.getTime() );
} else {
throw new KettleValueException( "Function last_day only works on a date" );
}
return this;
}
public Value first_day() throws KettleValueException {
if ( getType() == VALUE_TYPE_DATE ) {
Calendar cal = Calendar.getInstance();
cal.setTime( getDate() );
cal.set( Calendar.DAY_OF_MONTH, 1 );
setValue( cal.getTime() );
} else {
throw new KettleValueException( "Function first_day only works on a date" );
}
return this;
}
// implement the TRUNC function, version without arguments
public Value trunc() throws KettleValueException {
if ( isNull() ) {
return this; // don't do anything, leave it at NULL!
}
if ( isInteger() ) {
// Nothing
return this;
}
if ( isBigNumber() ) {
getBigNumber().setScale( 0, BigDecimal.ROUND_FLOOR );
} else if ( isNumber() ) {View on GitHub (pinned to f3058517a1)