{"record":{"id":"48709fdeafb64dba","repo":"prestodb/presto","slug":"datatype-mismatch-48709f","errorCode":"DATATYPE_MISMATCH","errorMessage":"Mismatched Domain types: %s vs %s","messagePattern":"Mismatched Domain types: (.+?) vs (.+?)","errorType":"error_code","errorClass":"DataTypeMismatchException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/predicate/Domain.java","lineNumber":233,"sourceCode":"\n        return new Domain(unionedValues, nullAllowed);\n    }\n\n    public Domain complement()\n    {\n        return new Domain(values.complement(), !nullAllowed);\n    }\n\n    public Domain subtract(Domain other)\n    {\n        checkCompatibility(other);\n        return new Domain(values.subtract(other.getValues()), this.isNullAllowed() && !other.isNullAllowed());\n    }\n\n    private void checkCompatibility(Domain domain)\n    {\n        if (!getType().equals(domain.getType())) {\n            throw new DataTypeMismatchException(String.format(\"Mismatched Domain types: %s vs %s\", getType(), domain.getType()));\n        }\n        if (values.getClass() != domain.values.getClass()) {\n            throw new DataTypeMismatchException(String.format(\"Mismatched Domain value set classes: %s vs %s\", values.getClass(), domain.values.getClass()));\n        }\n    }\n\n    @Override\n    public int hashCode()\n    {\n        return Objects.hash(values, nullAllowed);\n    }\n\n    @Override\n    public boolean equals(Object obj)\n    {\n        if (this == obj) {\n            return true;\n        }","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/predicate/Domain.java#L215-L251","documentation":"Domain.checkCompatibility ensures binary Domain operations (overlaps, contains, intersect, union, subtract) are only applied to Domains of the same Presto Type, throwing DataTypeMismatchException otherwise.","triggerScenarios":"Calling any of overlaps/contains/intersect/union/subtract with a Domain whose getType() differs, e.g. intersecting a BIGINT domain with an INTEGER domain.","commonSituations":"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.","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"],"exampleFix":"// before\ndomainA.intersect(domainB); // BIGINT vs INTEGER\n// after\ncheckState(domainA.getType().equals(domainB.getType()), \"type mismatch\");\ndomainA.intersect(domainB);","handlingStrategy":"validation","validationCode":"if (!domainA.getType().equals(domainB.getType())) {\n    throw new IllegalArgumentException(\"Domain type mismatch: \" + domainA.getType() + \" vs \" + domainB.getType());\n}\ndomainA.intersect(domainB);","typeGuard":null,"tryCatchPattern":"try { return a.union(b); } catch (DataTypeMismatchException e) { /* fall back to no-filter domain or surface planner error */ }","preventionTips":["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"],"tags":["domain","datatype-mismatch","predicate"],"backgroundTag":"datatype-mismatch","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}