{"record":{"id":"67e9fc6b09542923","repo":"prestodb/presto","slug":"datasize-must-be-greater-than-or-equal-to-0-s","errorCode":null,"errorMessage":"dataSize must be greater than or equal to 0: %s","messagePattern":"dataSize must be greater than or equal to 0: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-spi/src/main/java/com/facebook/presto/spi/statistics/ColumnStatistics.java","lineNumber":82,"sourceCode":"            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    {\n        return nullsFraction;\n    }\n\n    @JsonProperty\n    public Estimate getDistinctValuesCount()\n    {\n        return distinctValuesCount;\n    }\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spi/src/main/java/com/facebook/presto/spi/statistics/ColumnStatistics.java#L64-L100","documentation":"Constructor invariant check in ColumnStatistics: the provided dataSize Estimate is known but negative, which is invalid for a byte-size statistic. This IllegalArgumentException enforces sane optimizer statistics from connectors.","triggerScenarios":"Constructing ColumnStatistics with a dataSize Estimate whose value is negative, e.g. from totalSize/rowCount rounding bugs or corrupted table stats.","commonSituations":"Connectors deriving average row size from total size and row count where totalSize is misreported as negative.","solutions":["Fix the connector's statistics provider so data sizes are non-negative","Return an unknown Estimate when the size cannot be computed reliably"],"exampleFix":"// before\nEstimate.of(totalSize / rowCount)\n// after\nEstimate.of(Math.max(0, totalSize / rowCount))","handlingStrategy":"validation","validationCode":"if (size != null && !size.isUnknown() && size.getValue() < 0) { throw new IllegalArgumentException(\"dataSize negative: \" + size.getValue()); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard against negative sizes from external metastores","Clamp with Math.max(0, size)","Emit unknown when total size or row count is missing"],"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"}