pentaho/pentaho-kettle · error · KettleValueException
Unknown result type option
Error message
Unknown result type option '<resultType>'
What it means
ValueDataUtil.DateDiff validates its resultType argument against the known units s/m/h/d (seconds, minutes, hours, days). Any other string reaches the final else and throws this KettleValueException naming the offending value.
Solutions
- Pass exactly one of "s", "m", "h", "d" (lowercase, single letter) as resultType
- Check the step configuration/variable supplying the unit and fix its value
- Validate/normalize the unit string before calling: lower-case it and map full words to the codes
- For finer units (ms, weeks, months) do the arithmetic yourself from the ms diff instead of passing an unsupported code
Example fix
// before Object diff = ValueDataUtil.dateDiff( metaA, dA, metaB, dB, "minutes" ); // after String unit = "minutes".startsWith( "m" ) ? "m" : "minutes"; // map to supported code Object diff = ValueDataUtil.dateDiff( metaA, dA, metaB, dB, unit ); // "s"|"m"|"h"|"d"
Defensive patterns
Strategy: validation
Validate before calling
java.util.Arrays.asList( "s", "m", "h", "d" ).contains( resultType ); // false => fix before calling
Type guard
boolean isSupportedDiffUnit( String u ) { return u != null && u.matches( "[smhd]" ); } Try / catch
if ( !isSupportedDiffUnit( resultType ) ) {
throw new IllegalArgumentException( "resultType must be s|m|h|d, got: " + resultType );
}
return ValueDataUtil.dateDiff( metaA, dataA, metaB, dataB, resultType ); Prevention
- Never pass spelled-out units; only single lowercase letters s/m/h/d
- Normalize user/variable-supplied units: trim, toLowerCase, map synonyms
- If units come from variables, validate them once at transformation init
When it happens
Trigger: Calling ValueDataUtil.dateDiff(metaA, dataA, metaB, dataB, resultType) with resultType not exactly one of "s", "m", "h", "d" — e.g. "S", "seconds", "ms", "y" or a null-but-nonempty variant from a variable substitution.
Common situations: Calculator/UDF step configured with a unit spelled out ('minutes') instead of the single-letter code; a transformation variable used for the unit is unset or mistyped; case-sensitivity surprise ('M' vs 'm').
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- The source and target step/copy can't be the same for a…
- A connection of type PALO is expected
- A connection of type PALO is expected
- A deadlock was detected between steps
- A module with id ' ' is not defined.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/ffd237addcaa3e3b.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/row/ValueDataUtil.java:1618
long endL = endDateCal.getTimeInMillis() + endDateCal.getTimeZone().getOffset( endDateCal.getTimeInMillis() );
long startL = stDateCal.getTimeInMillis() + stDateCal.getTimeZone().getOffset( stDateCal.getTimeInMillis() );
long diff = endL - startL;
if ( Utils.isEmpty( resultType ) ) {
return new Long( diff / 86400000 );
} else if ( resultType.equals( "ms" ) ) {
return new Long( diff );
} else if ( resultType.equals( "s" ) ) {
return new Long( diff / 1000 ); // second
} else if ( resultType.equals( "mn" ) ) {
return new Long( diff / 60000 ); // minute
} else if ( resultType.equals( "h" ) ) {
return new Long( diff / 3600000 ); // hour
} else if ( resultType.equals( "d" ) ) {
return new Long( diff / 86400000 );
} else {
throw new KettleValueException( "Unknown result type option '" + resultType + "'" );
}
} else {
return null;
}
}
public static Object DateWorkingDiff( ValueMetaInterface metaA, Object dataA, ValueMetaInterface metaB,
Object dataB ) throws KettleValueException {
if ( dataA != null && dataB != null ) {
Date fromDate = metaB.getDate( dataB );
Date toDate = metaA.getDate( dataA );
boolean singminus = false;
if ( fromDate.after( toDate ) ) {
singminus = true;
Date temp = fromDate;
fromDate = toDate;
toDate = temp;View on GitHub (pinned to f3058517a1)