{"record":{"id":"652973b2c95122ee","repo":"prestodb/presto","slug":"nullsfraction-must-be-between-0-and-1-s","errorCode":null,"errorMessage":"nullsFraction must be between 0 and 1: %s","messagePattern":"nullsFraction must be between 0 and 1: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-spi/src/main/java/com/facebook/presto/spi/statistics/ColumnStatistics.java","lineNumber":73,"sourceCode":"            Estimate dataSize,\n            Optional<DoubleRange> range,\n            Optional<ConnectorHistogram> histogram)\n    {\n        this(nullsFraction, distinctValuesCount, dataSize, range, Optional.empty(), histogram);\n    }\n\n    public ColumnStatistics(\n            Estimate nullsFraction,\n            Estimate distinctValuesCount,\n            Estimate dataSize,\n            Optional<DoubleRange> range,\n            Optional<StringRange> stringRange,\n            Optional<ConnectorHistogram> histogram)\n    {\n        this.nullsFraction = requireNonNull(nullsFraction, \"nullsFraction is null\");\n        if (!nullsFraction.isUnknown()) {\n            if (nullsFraction.getValue() < 0 || nullsFraction.getValue() > 1) {\n                throw new IllegalArgumentException(format(\"nullsFraction must be between 0 and 1: %s\", nullsFraction.getValue()));\n            }\n        }\n        this.distinctValuesCount = requireNonNull(distinctValuesCount, \"distinctValuesCount is null\");\n        if (!distinctValuesCount.isUnknown() && distinctValuesCount.getValue() < 0) {\n            throw new IllegalArgumentException(format(\"distinctValuesCount must be greater than or equal to 0: %s\", distinctValuesCount.getValue()));\n        }\n        this.dataSize = requireNonNull(dataSize, \"dataSize is null\");\n        if (!dataSize.isUnknown() && dataSize.getValue() < 0) {\n            throw new IllegalArgumentException(format(\"dataSize must be greater than or equal to 0: %s\", dataSize.getValue()));\n        }\n        this.range = requireNonNull(range, \"range is null\");\n        this.stringRange = requireNonNull(stringRange, \"string range is null\");\n        this.histogram = requireNonNull(histogram, \"histogram is null\");\n    }\n\n    @JsonProperty\n    public Estimate getNullsFraction()\n    {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spi/src/main/java/com/facebook/presto/spi/statistics/ColumnStatistics.java#L55-L91","documentation":"ColumnStatistics enforces that the nulls fraction is a probability in [0,1] when the estimate is not UNKNOWN. Values outside that range are statistically impossible and indicate a buggy statistics producer.","triggerScenarios":"Calling ColumnStatistics constructor (or a builder producing it) with an Estimate whose value is < 0 or > 1, e.g. nullsFraction from a fraction computed as count/totalCount when totalCount is 0.","commonSituations":"Connector statistics code dividing by zero counts, computing percentages (0-100) instead of fractions (0-1), or scaling errors in histogram derivation.","solutions":["Convert percentage values to fractions (divide by 100) before building ColumnStatistics","Clamp the computed value into [0,1]","Use Estimate.unknown() when the fraction cannot be computed","Fix division-by-zero in the fraction calculation"],"exampleFix":"// before\nEstimate.nullsFraction(45.0) // percent\n// after\nEstimate.nullsFraction(0.45)","handlingStrategy":"validation","validationCode":"if (fraction != null && !fraction.isUnknown() && (fraction.getValue() < 0 || fraction.getValue() > 1)) { throw new IllegalArgumentException(\"nullsFraction out of [0,1]: \" + fraction.getValue()); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use fractions (0-1), never percentages, for null fractions","Clamp computed ratios with Math.min/Math.max","Return Estimate.unknown() when counts are zero or unavailable"],"tags":["spi","statistics","validation","optimizer"],"backgroundTag":"statistics-range-validation","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"}