apache/seatunnel · error · org.apache.seatunnel.api.configuration.util.OptionValidationException
Cannot compare values of type %s and %s
Error message
Cannot compare values of type %s and %s
What it means
Thrown from ConditionEvaluators.compareNumbers when both operands are non-null but neither pair of types is mutually comparable: they are not both Numbers and not both Comparables of compatible type. At its throw site it means the conditional expression compares values of mismatched kinds (e.g. a string against a number, or a list against a scalar); the guard reports the two runtime classes so the mis-typed operand in the condition can be located.
Source
Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/configuration/util/ConditionEvaluators.java:197
}
}
return Collections.unmodifiableMap(m);
}
@SuppressWarnings({"rawtypes"})
static int compareNumbers(Object a, Object b) {
if (a == null || b == null) {
throw new OptionValidationException(
"Cannot compare null values in numeric comparison: leftPresent=%s, rightPresent=%s",
a != null, b != null);
}
if (a instanceof Number && b instanceof Number) {
return compareNumberValues((Number) a, (Number) b);
}
if (a instanceof Comparable && b instanceof Comparable) {
return ((Comparable) a).compareTo(b);
}
throw new OptionValidationException(
"Cannot compare values of type %s and %s",
a.getClass().getSimpleName(), b.getClass().getSimpleName());
}
private static int compareNumberValues(Number a, Number b) {
if (a instanceof BigDecimal || b instanceof BigDecimal) {
BigDecimal bdA =
a instanceof BigDecimal ? (BigDecimal) a : new BigDecimal(a.toString());
BigDecimal bdB =
b instanceof BigDecimal ? (BigDecimal) b : new BigDecimal(b.toString());
return bdA.compareTo(bdB);
}
if (a instanceof Double
|| a instanceof Float
|| b instanceof Double
|| b instanceof Float) {
return Double.compare(a.doubleValue(), b.doubleValue());
}View on GitHub (pinned to cf67b549a7)
Solutions
- Make both sides of the condition the same type — quote string values or write numeric literals without quotes in the config
- Check the option's declared type in its Option definition and write the comparison value to match
- If comparing enums or custom types, ensure both operands implement Comparable with a common comparable type
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/configuration/util/ConditionEvaluators.java:197 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/10a7bb1262564b32.
Report an issue: GitHub.