prestodb/presto · error · DataTypeMismatchException
DATATYPE_MISMATCH
DATATYPE_MISMATCH
Error message
Mismatched Domain types: %s vs %s
What it means
Domain.checkCompatibility ensures binary Domain operations (overlaps, contains, intersect, union, subtract) are only applied to Domains of the same Presto Type, throwing DataTypeMismatchException otherwise.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/predicate/Domain.java:233
return new Domain(unionedValues, nullAllowed);
}
public Domain complement()
{
return new Domain(values.complement(), !nullAllowed);
}
public Domain subtract(Domain other)
{
checkCompatibility(other);
return new Domain(values.subtract(other.getValues()), this.isNullAllowed() && !other.isNullAllowed());
}
private void checkCompatibility(Domain domain)
{
if (!getType().equals(domain.getType())) {
throw new DataTypeMismatchException(String.format("Mismatched Domain types: %s vs %s", getType(), domain.getType()));
}
if (values.getClass() != domain.values.getClass()) {
throw new DataTypeMismatchException(String.format("Mismatched Domain value set classes: %s vs %s", values.getClass(), domain.values.getClass()));
}
}
@Override
public int hashCode()
{
return Objects.hash(values, nullAllowed);
}
@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}View on GitHub (pinned to 55bb57d202)
Solutions
- Verify domain.getType().equals(other.getType()) before combining; coerce if necessary
- Construct all Domains for a column from one canonical Type object
- In connector code, translate predicates per-column using that column's declared Type
- Add a compatibility check upstream and surface a clearer query-planning error instead
Example fix
// before domainA.intersect(domainB); // BIGINT vs INTEGER // after checkState(domainA.getType().equals(domainB.getType()), "type mismatch"); domainA.intersect(domainB);
Defensive patterns
Strategy: validation
Validate before calling
if (!domainA.getType().equals(domainB.getType())) {
throw new IllegalArgumentException("Domain type mismatch: " + domainA.getType() + " vs " + domainB.getType());
}
domainA.intersect(domainB); Try / catch
try { return a.union(b); } catch (DataTypeMismatchException e) { /* fall back to no-filter domain or surface planner error */ } Prevention
- Check Types before every Domain binary operation
- Build Domains from a single source of truth for column types
- Add early compatibility assertions in predicate-merge helpers
When it happens
Trigger: Calling any of overlaps/contains/intersect/union/subtract with a Domain whose getType() differs, e.g. intersecting a BIGINT domain with an INTEGER domain.
Common situations: Merging tuple domains from different sources in predicate pushdown; comparing stats-derived domains with query-derived domains of mismatched type; column type changes across cache generations.
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/48709fdeafb64dba.
Report an issue: GitHub.