{"record":{"id":"1833ecaa662e65ea","repo":"prestodb/presto","slug":"datatype-mismatch","errorCode":"DATATYPE_MISMATCH","errorMessage":"Mismatched types: %s vs %s","messagePattern":"Mismatched types: (.+?) vs (.+?)","errorType":"error_code","errorClass":"DataTypeMismatchException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/predicate/AllOrNoneValueSet.java","lineNumber":174,"sourceCode":"\n    @Override\n    public boolean equals(Object obj)\n    {\n        if (this == obj) {\n            return true;\n        }\n        if (obj == null || getClass() != obj.getClass()) {\n            return false;\n        }\n        final AllOrNoneValueSet other = (AllOrNoneValueSet) obj;\n        return Objects.equals(this.type, other.type)\n                && this.all == other.all;\n    }\n\n    private AllOrNoneValueSet checkCompatibility(ValueSet other)\n    {\n        if (!getType().equals(other.getType())) {\n            throw new DataTypeMismatchException(String.format(\"Mismatched types: %s vs %s\", getType(), other.getType()));\n        }\n        if (!(other instanceof AllOrNoneValueSet)) {\n            throw new IllegalArgumentException(String.format(\"ValueSet is not a AllOrNoneValueSet: %s\", other.getClass()));\n        }\n        return (AllOrNoneValueSet) other;\n    }\n}\n","sourceCodeStart":156,"sourceCodeEnd":182,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/predicate/AllOrNoneValueSet.java#L156-L182","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\nValueSet merged = setA.union(setB); // INTEGER vs BIGINT\n// after\nif (setA.getType().equals(setB.getType())) {\n    ValueSet merged = setA.union(setB);\n} else {\n    setB = coerce(setB, setA.getType());\n}","handlingStrategy":"validation","validationCode":"if (!a.getType().equals(b.getType())) {\n    b = (ValueSet) coerceToType(b, a.getType()); // or handle mismatch explicitly\n}\nValueSet merged = a.union(b);","typeGuard":null,"tryCatchPattern":"try { return a.union(b); } catch (DataTypeMismatchException e) { throw new SemanticException(TYPE_MISMATCH, \"cannot combine sets: \" + e.getMessage()); }","preventionTips":["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)"],"tags":["predicate","datatype-mismatch","domain"],"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"}