prestodb/presto · error · DataTypeMismatchException
DATATYPE_MISMATCH
DATATYPE_MISMATCH
Error message
Mismatched types: %s vs %s
What it means
AllOrNoneValueSet.checkCompatibility validates that set operations (union, intersect, overlaps, etc. via otherValueSet) are performed on ValueSets of the same Presto Type. A mismatch throws DataTypeMismatchException.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/predicate/AllOrNoneValueSet.java:174
@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final AllOrNoneValueSet other = (AllOrNoneValueSet) obj;
return Objects.equals(this.type, other.type)
&& this.all == other.all;
}
private AllOrNoneValueSet checkCompatibility(ValueSet other)
{
if (!getType().equals(other.getType())) {
throw new DataTypeMismatchException(String.format("Mismatched types: %s vs %s", getType(), other.getType()));
}
if (!(other instanceof AllOrNoneValueSet)) {
throw new IllegalArgumentException(String.format("ValueSet is not a AllOrNoneValueSet: %s", other.getClass()));
}
return (AllOrNoneValueSet) other;
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure both ValueSets derive from Domains of the same Type before combining
- Coerce one side to the other's Type using the type's coercion functions before set operations
- Check with valueSet.getType().equals(other.getType()) before union/intersect
- Fix upstream metadata so the same column always produces the same Type
Example fix
// before
ValueSet merged = setA.union(setB); // INTEGER vs BIGINT
// after
if (setA.getType().equals(setB.getType())) {
ValueSet merged = setA.union(setB);
} else {
setB = coerce(setB, setA.getType());
} Defensive patterns
Strategy: validation
Validate before calling
if (!a.getType().equals(b.getType())) {
b = (ValueSet) coerceToType(b, a.getType()); // or handle mismatch explicitly
}
ValueSet merged = a.union(b); Try / catch
try { return a.union(b); } catch (DataTypeMismatchException e) { throw new SemanticException(TYPE_MISMATCH, "cannot combine sets: " + e.getMessage()); } Prevention
- Compare Type objects with equals before any ValueSet/Domain binary op
- Derive all predicates for a column from one canonical Type
- Key caches by (column, type)
When it happens
Trigger: Combining two ValueSets whose getType() differ, e.g. union of an INTEGER AllOrNoneValueSet with a BIGINT one, or VARCHAR vs DATE sets in predicate pushdown merging.
Common situations: Merging partition domains from different tables/columns with same-named but different types; connector predicate translation bugs; type evolution (column type changed between cached domains).
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/1833ecaa662e65ea.
Report an issue: GitHub.