prestodb/presto · error · PrestoException

INVALID_ARGUMENTS

INVALID_ARGUMENTS

Error message

can't create kll sketch from type: %s

What it means

KllHistogram builds a KLL items sketch from serialized Iceberg statistics blobs and needs converter functions for the sketch's element type. Only Double and Long-backed types have toDouble/fromDouble converters defined; any other serde class type reaches the else branch and throws PrestoException(INVALID_ARGUMENTS).

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/statistics/KllHistogram.java:86

    public KllHistogram(@JsonProperty("sketch") Slice bytes, @JsonProperty("type") Type type)
    {
        verify(isKllHistogramSupportedType(type), "histograms do not currently support type " + type.getDisplayName());
        this.type = requireNonNull(type, "type is null");
        SketchParameters parameters = getSketchParameters(type);
        // the actual sketch can only accept the same object types which generated it
        // however, the API can only accept or generate double types. We cast the inputs
        // and results to/from double to satisfy the underlying sketch type.
        if (parameters.getSerde().getClassOfT().equals(Double.class)) {
            toDouble = x -> (double) x;
            fromDouble = x -> x;
        }
        else if (parameters.getSerde().getClassOfT().equals(Long.class)) {
            // dual cast to auto-box/unbox from Double/Long for sketch
            toDouble = x -> (double) (long) x;
            fromDouble = x -> (long) (double) x;
        }
        else {
            throw new PrestoException(INVALID_ARGUMENTS, "can't create kll sketch from type: " + type);
        }
        sketch = KllItemsSketch.wrap(Memory.wrap(bytes.toByteBuffer(), LITTLE_ENDIAN), parameters.getComparator(), parameters.getSerde());
    }

    public static boolean isKllHistogramSupportedType(Type type)
    {
        try {
            return isNumericType(type) ||
                    type instanceof AbstractIntType;
        }
        catch (PrestoException e) {
            return false;
        }
    }

    @JsonProperty
    public Slice getSketch()
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Ensure only supported types (Double/Long-backed) are used for KLL sketch columns when writing statistics, or drop statistics on unsupported columns
  2. Check isKllHistogramSupportedType(type) before enabling KLL histograms for a column
  3. Upgrade Presto to a version supporting the type, or disable the KLL statistics feature that produced the blob

Example fix

// before
Type columnType = DATE; // KLL sketch written for DATE
// after
if (KllHistogram.isKllHistogramSupportedType(columnType)) { /* use KLL */ } else { /* fall back to generic stats */ }
Defensive patterns

Strategy: validation

Validate before calling

if (!KllHistogram.isKllHistogramSupportedType(columnType)) {
    throw new IllegalArgumentException("KLL histogram not supported for type: " + columnType);
}

Type guard

boolean kllSupported(Type t) { return KllHistogram.isKllHistogramSupportedType(t); }

Try / catch

try {
    KllHistogram h = new KllHistogram(serde, bytes, type);
} catch (PrestoException e) {
    if (e.getErrorCode().getName().equals("INVALID_ARGUMENTS")) {
        log.warn("Skipping unsupported KLL statistics for " + type);
        return Optional.empty();
    }
    throw e;
}

Prevention

When it happens

Trigger: Constructing a KllHistogram from an Iceberg statistics blob whose column serde type is neither Double nor Long (e.g. a string or date-typed KLL sketch, or a serde returning an unexpected boxed class).

Common situations: Reading Iceberg table metadata produced by a writer that generated KLL sketches for types this Presto version does not support; upgrading/downgrading between Presto versions with different KLL type support; corrupted or hand-edited statistics metadata.

Related errors


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