prestodb/presto · error · IllegalArgumentException
dataSize must be greater than or equal to 0: %s
Error message
dataSize must be greater than or equal to 0: %s
What it means
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.
Source
Thrown at presto-spi/src/main/java/com/facebook/presto/spi/statistics/ColumnStatistics.java:82
Estimate distinctValuesCount,
Estimate dataSize,
Optional<DoubleRange> range,
Optional<StringRange> stringRange,
Optional<ConnectorHistogram> histogram)
{
this.nullsFraction = requireNonNull(nullsFraction, "nullsFraction is null");
if (!nullsFraction.isUnknown()) {
if (nullsFraction.getValue() < 0 || nullsFraction.getValue() > 1) {
throw new IllegalArgumentException(format("nullsFraction must be between 0 and 1: %s", nullsFraction.getValue()));
}
}
this.distinctValuesCount = requireNonNull(distinctValuesCount, "distinctValuesCount is null");
if (!distinctValuesCount.isUnknown() && distinctValuesCount.getValue() < 0) {
throw new IllegalArgumentException(format("distinctValuesCount must be greater than or equal to 0: %s", distinctValuesCount.getValue()));
}
this.dataSize = requireNonNull(dataSize, "dataSize is null");
if (!dataSize.isUnknown() && dataSize.getValue() < 0) {
throw new IllegalArgumentException(format("dataSize must be greater than or equal to 0: %s", dataSize.getValue()));
}
this.range = requireNonNull(range, "range is null");
this.stringRange = requireNonNull(stringRange, "string range is null");
this.histogram = requireNonNull(histogram, "histogram is null");
}
@JsonProperty
public Estimate getNullsFraction()
{
return nullsFraction;
}
@JsonProperty
public Estimate getDistinctValuesCount()
{
return distinctValuesCount;
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Fix the connector's statistics provider so data sizes are non-negative
- Return an unknown Estimate when the size cannot be computed reliably
Example fix
// before Estimate.of(totalSize / rowCount) // after Estimate.of(Math.max(0, totalSize / rowCount))
Defensive patterns
Strategy: validation
Validate before calling
if (size != null && !size.isUnknown() && size.getValue() < 0) { throw new IllegalArgumentException("dataSize negative: " + size.getValue()); } Prevention
- Guard against negative sizes from external metastores
- Clamp with Math.max(0, size)
- Emit unknown when total size or row count is missing
When it happens
Trigger: Constructing ColumnStatistics with a dataSize Estimate whose value is negative, e.g. from totalSize/rowCount rounding bugs or corrupted table stats.
Common situations: Connectors deriving average row size from total size and row count where totalSize is misreported as negative.
Related errors
- nullsFraction must be between 0 and 1: %s
- distinctValuesCount must be greater than or equal to 0: %s
- catalogName is empty
- columns is empty
- NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/67e9fc6b09542923.
Report an issue: GitHub.