pentaho/pentaho-kettle · error · KettleValueException
: Comparing values can not be done with data type :
Error message
: Comparing values can not be done with data type :
What it means
ValueMetaBase.typeCompare() compares two values by switching on getType(); known types are String, Integer, Number, Date, BigNumber, Boolean, Binary. Any other type code (e.g. TYPE_NONE, -1, or a type from an unrecognized ValueMeta subclass) falls to the default branch and throws this KettleValueException. It means sorting/comparing was attempted on a value whose data type is not comparable.
Solutions
- Set a concrete comparable type on the value metadata before sorting/comparing (e.g. setType(ValueMetaInterface.TYPE_STRING)).
- Filter out or convert TYPE_NONE / unsupported fields before steps that sort or compare rows.
- Provide a custom Comparator via setComparator() on the ValueMeta so compare() bypasses the type switch.
- Check plugin-supplied fields and register/convert their types to core Kettle types before comparison.
Example fix
// before
ValueMetaInterface meta = new ValueMeta("x"); // type = TYPE_NONE
rows.sort(meta.compare(...)); // throws
// after
ValueMetaInterface meta = new ValueMeta("x", ValueMetaInterface.TYPE_STRING);
if (meta.getType() == ValueMetaInterface.TYPE_NONE) {
meta.setType(ValueMetaInterface.TYPE_STRING);
} Defensive patterns
Strategy: validation
Validate before calling
if (meta.getType() == ValueMetaInterface.TYPE_NONE) {
throw new IllegalStateException("Field " + meta.toStringMeta() + " has no comparable type");
} Type guard
boolean isComparable(ValueMetaInterface m) {
switch (m.getType()) {
case ValueMetaInterface.TYPE_STRING:
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_NUMBER:
case ValueMetaInterface.TYPE_DATE:
case ValueMetaInterface.TYPE_BIGNUMBER:
case ValueMetaInterface.TYPE_BOOLEAN:
case ValueMetaInterface.TYPE_BINARY:
return true;
default:
return false;
}
} Try / catch
try { rows.sort(comparatorUsingMeta); } catch (KettleValueException e) {
if (e.getMessage().contains("Comparing values can not be done")) {
logger.logError("Non-comparable field type in sort: " + e.getMessage());
}
throw e;
} Prevention
- Always construct ValueMeta with an explicit type argument.
- Scrub TYPE_NONE fields with a Select Values step before sort/group/merge.
- Register custom comparators via setComparator() for plugin-specific types.
- Run transformation metadata checks (transMeta.checkSteps) before execution.
When it happens
Trigger: Calling compare(Object,Object), or any sort/group/merge that uses it, on a ValueMetaBase whose type is TYPE_NONE (0) or otherwise unhandled — typically a ValueMeta created without a valid type or with a type not mapped in typeCompare.
Common situations: Building ValueMeta with new ValueMeta("x") and forgetting to set a type; passing TYPE_NONE fields into Sort Rows / Merge Join / Group By steps; custom ValueMeta implementations returning unsupported type codes; fields from plugins with types unknown to core comparison.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- : I can't convert the specified value to data type :
- : Unable to compare with value []
- : Unknown storage type :
- API coding error: please specify the conversion metadata…
- Calculator.Error.NoNameField
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/59d6f3db11f4e463.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:3769
byte[] b1 = (byte[]) data1;
byte[] b2 = (byte[]) data2;
int length = b1.length < b2.length ? b1.length : b2.length;
cmp = b1.length - b2.length;
if ( cmp == 0 ) {
for ( int i = 0; i < length; i++ ) {
cmp = b1[ i ] - b2[ i ];
if ( cmp != 0 ) {
cmp = cmp < 0 ? -1 : 1;
break;
}
}
}
break;
default:
throw new KettleValueException( toString() + " : Comparing values can not be done with data type : "
+ getType() );
}
return cmp;
}
/**
* Compare 2 values of the same data type
*
* @param data1
* the first value
* @param meta2
* the second value's metadata
* @param data2
* the second value
* @return 0 if the values are equal, -1 if data1 is smaller than data2 and +1 if it's larger.
* @throws KettleValueException
* In case we get conversion errorsView on GitHub (pinned to f3058517a1)