prestodb/presto · error · DataTypeMismatchException
DATATYPE_MISMATCH
DATATYPE_MISMATCH
Error message
Mismatched types: %s vs %s
What it means
EquatableValueSet.checkCompatibility requires that set operations are performed against another ValueSet of the same Presto Type and the same EquatableValueSet implementation; a Type mismatch throws DataTypeMismatchException, and a wrong implementation throws IllegalStateException (separate message).
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/predicate/EquatableValueSet.java:293
}
private static <T> Set<T> union(Set<T> set1, Set<T> set2)
{
return Stream.concat(set1.stream(), set2.stream())
.collect(toLinkedSet());
}
private static <T> Set<T> subtract(Set<T> set1, Set<T> set2)
{
return set1.stream()
.filter(value -> !set2.contains(value))
.collect(toLinkedSet());
}
private EquatableValueSet checkCompatibility(ValueSet other)
{
if (!getType().equals(other.getType())) {
throw new DataTypeMismatchException(String.format("Mismatched types: %s vs %s", getType(), other.getType()));
}
if (!(other instanceof EquatableValueSet)) {
throw new IllegalStateException(String.format("ValueSet is not a EquatableValueSet: %s", other.getClass()));
}
return (EquatableValueSet) other;
}
@Override
public int hashCode()
{
return Objects.hash(type, whiteList, entries);
}
@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure both sets have equal Type before combining; coerce one side if needed
- Build both sets via ValueSet.of(type, ...) with identical Type instances
- Key any ValueSet/Domain caches by (column, type) not just column
- Pre-check with setA.getType().equals(setB.getType()) and handle mismatch explicitly
Example fix
// before
ValueSet merged = varcharSet.union(intSet); // throws
// after
if (varcharSet.getType().equals(intSet.getType())) {
ValueSet merged = varcharSet.union(intSet);
} Defensive patterns
Strategy: validation
Validate before calling
if (!a.getType().equals(b.getType())) {
throw new IllegalArgumentException("ValueSet type mismatch: " + a.getType() + " vs " + b.getType());
}
ValueSet merged = a.union(b); Try / catch
try { return a.union(b); } catch (DataTypeMismatchException e) { /* treat as incompatible predicates; widen to none/all */ } Prevention
- Construct ValueSets with the exact same Type instance per column
- Include type in cache keys for stored predicates
- Coerce before combining rather than relying on runtime checks
When it happens
Trigger: Calling union/intersect/overlaps/contains via otherValueSet with a ValueSet of a different Type, e.g. combining a VARCHAR EquatableValueSet with an INTEGER one.
Common situations: Merging discrete value sets from different columns or mismatched partition key types; predicate translation bugs in connectors; caching ValueSets keyed only by column name after a type change.
Related errors
- DATATYPE_MISMATCH
- DATATYPE_MISMATCH
- Value class %s does not match required Type class %s
- DRUID_PUSHDOWN_UNSUPPORTED_EXPRESSION
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/3208db0c9bed1519.
Report an issue: GitHub.