{"record":{"id":"a4f6c046c17de36f","repo":"prestodb/presto","slug":"write-validation-failed-unexpected-double-range-i","errorCode":null,"errorMessage":"Write validation failed: unexpected double range in %s statistics","messagePattern":"Write validation failed: unexpected double range in (.+?) statistics","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/OrcWriteValidation.java","lineNumber":556,"sourceCode":"        }\n        if (!Objects.equals(actualColumnStatistics.getIntegerStatistics(), expectedColumnStatistics.getIntegerStatistics())) {\n            IntegerStatistics actualIntegerStatistics = actualColumnStatistics.getIntegerStatistics();\n            IntegerStatistics expectedIntegerStatistics = expectedColumnStatistics.getIntegerStatistics();\n            // The sum of the integer stats depends on the order of how we merge them.\n            // It is possible the sum can overflow with one order but not in another.\n            // Ignore the validation of sum if one of the two sums is null.\n            if (actualIntegerStatistics == null ||\n                    expectedIntegerStatistics == null ||\n                    !Objects.equals(actualIntegerStatistics.getMin(), expectedIntegerStatistics.getMin()) ||\n                    !Objects.equals(actualIntegerStatistics.getMax(), expectedIntegerStatistics.getMax()) ||\n                    (actualIntegerStatistics.getSum() != null &&\n                            expectedIntegerStatistics.getSum() != null &&\n                            !Objects.equals(actualIntegerStatistics.getSum(), expectedIntegerStatistics.getSum()))) {\n                throw new OrcCorruptionException(orcDataSourceId, \"Write validation failed: unexpected integer range in %s statistics\", name);\n            }\n        }\n        if (!Objects.equals(actualColumnStatistics.getDoubleStatistics(), expectedColumnStatistics.getDoubleStatistics())) {\n            throw new OrcCorruptionException(orcDataSourceId, \"Write validation failed: unexpected double range in %s statistics\", name);\n        }\n        StringStatistics expectedStringStatistics = expectedColumnStatistics.getStringStatistics();\n        if (expectedStringStatistics != null) {\n            expectedStringStatistics = new StringStatistics(\n                    minStringTruncateToValidRange(expectedStringStatistics.getMin(), HiveWriterVersion.ORC_HIVE_8732),\n                    maxStringTruncateToValidRange(expectedStringStatistics.getMax(), HiveWriterVersion.ORC_HIVE_8732),\n                    expectedStringStatistics.isLowerBoundSet(),\n                    expectedStringStatistics.isUpperBoundSet(),\n                    expectedStringStatistics.getSum());\n        }\n        StringStatistics actualStringStatistics = actualColumnStatistics.getStringStatistics();\n        if (!Objects.equals(actualColumnStatistics.getStringStatistics(), expectedStringStatistics) && expectedStringStatistics != null) {\n            // expectedStringStatistics (or the min/max of it) could be null while the actual one might not because\n            // expectedStringStatistics is calculated by merging all row group stats in the stripe but the actual one is by scanning each row in the stripe on disk.\n            // Merging row group stats can produce nulls given we have string stats limit.\n            if (actualStringStatistics == null ||\n                    actualStringStatistics.getSum() != expectedStringStatistics.getSum() ||\n                    (expectedStringStatistics.getMax() != null && !Objects.equals(actualStringStatistics.getMax(), expectedStringStatistics.getMax())) ||","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/OrcWriteValidation.java#L538-L574","documentation":"For double columns, write validation compares DoubleStatistics (min/max) recorded at write time against those read from the file. Objects.equals on DoubleStatistics is exact; any difference (including NaN representation differences across writers) makes validation fail, treating the file as possibly corrupt.","triggerScenarios":"validateColumnStatisticsEquivalent finds actualColumnStatistics.getDoubleStatistics() not equal to expectedColumnStatistics.getDoubleStatistics() — min or max differ, or null vs non-null, at any validation level.","commonSituations":"Files written by other ORC engines that serialize NaN or -0.0 differently; corrupted double columns; floating-point stats computed with different precision by other writers.","solutions":["Re-write the file with the Presto ORC writer to normalize double statistics","Check whether the file came from another engine (Hive/Spark) and disable orc.write-validation for it","Restore the file if genuine corruption is suspected (verify with storage checksums)","Upgrade Presto if a double statistics equality bug matches your version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    orcBatchReader.nextPage();\n} catch (OrcCorruptionException e) {\n    if (e.getMessage().contains(\"unexpected double range\")) {\n        // check for cross-engine NaN/-0.0 serialization differences before declaring corruption\n    }\n}","preventionTips":["Avoid mixing ORC writers with different NaN/-0.0 statistics conventions","Re-write cross-engine files with Presto's writer","Keep Presto versions aligned","Enable storage checksums"],"tags":["orc","write-validation","statistics","double"],"backgroundTag":"orc-write-validation-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"}