prestodb/presto · error · IllegalArgumentException

value must be > 0, found:

Error message

value must be > 0, found: 

What it means

SplitWeight wraps a strictly positive internal long value. The @ThriftConstructor SplitWeight(long value) throws IllegalArgumentException("value must be > 0, found: ...") if a non-positive raw value is supplied.

Source

Thrown at presto-spi/src/main/java/com/facebook/presto/spi/SplitWeight.java:42

import java.util.function.Function;

import static java.lang.Math.addExact;
import static java.lang.Math.multiplyExact;

@ThriftStruct
public final class SplitWeight
{
    private static final long UNIT_VALUE = 100;
    private static final int UNIT_SCALE = 2; // Decimal scale such that (10 ^ UNIT_SCALE) == UNIT_VALUE
    private static final SplitWeight STANDARD_WEIGHT = new SplitWeight(UNIT_VALUE);

    private final long value;

    @ThriftConstructor
    public SplitWeight(long value)
    {
        if (value <= 0) {
            throw new IllegalArgumentException("value must be > 0, found: " + value);
        }
        this.value = value;
    }

    /**
     * @return The internal integer representation for this weight value
     */
    @JsonValue
    @ThriftField(value = 1, name = "value")
    public long getRawValue()
    {
        return value;
    }

    @Override
    public boolean equals(Object other)
    {
        if (!(other instanceof SplitWeight)) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Ensure raw weight values are strictly positive before constructing; use SplitWeight.fromProportion for fractions
  2. Fix serialization/deserialization so defaults become STANDARD_WEIGHT rather than 0
  3. Guard: if (raw <= 0) use SplitWeight.STANDARD_WEIGHT instead of new SplitWeight(raw)

Example fix

// before
SplitWeight w = new SplitWeight(0);
// after
SplitWeight w = raw > 0 ? new SplitWeight(raw) : SplitWeight.STANDARD_WEIGHT;
Defensive patterns

Strategy: validation

Validate before calling

if (rawValue <= 0) throw new IllegalArgumentException("raw value must be > 0: " + rawValue);

Prevention

When it happens

Trigger: Constructing SplitWeight directly (or deserializing via Thrift/JSON) with raw value <= 0, e.g. SplitWeight.fromRawValue(0) or new SplitWeight(-5).

Common situations: Persisting split weights to a store that zeros them out; computing raw weights with integer division that truncates to 0; deserializing old/partial data lacking a weight value (default 0).

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/26c937e89c678d7c. Report an issue: GitHub.