{"record":{"id":"89b708bb9b185dbd","repo":"prestodb/presto","slug":"invalid-arguments-89b708","errorCode":"INVALID_ARGUMENTS","errorMessage":"can't create kll sketch from type: %s","messagePattern":"can't create kll sketch from type: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/statistics/KllHistogram.java","lineNumber":86,"sourceCode":"    public KllHistogram(@JsonProperty(\"sketch\") Slice bytes, @JsonProperty(\"type\") Type type)\n    {\n        verify(isKllHistogramSupportedType(type), \"histograms do not currently support type \" + type.getDisplayName());\n        this.type = requireNonNull(type, \"type is null\");\n        SketchParameters parameters = getSketchParameters(type);\n        // the actual sketch can only accept the same object types which generated it\n        // however, the API can only accept or generate double types. We cast the inputs\n        // and results to/from double to satisfy the underlying sketch type.\n        if (parameters.getSerde().getClassOfT().equals(Double.class)) {\n            toDouble = x -> (double) x;\n            fromDouble = x -> x;\n        }\n        else if (parameters.getSerde().getClassOfT().equals(Long.class)) {\n            // dual cast to auto-box/unbox from Double/Long for sketch\n            toDouble = x -> (double) (long) x;\n            fromDouble = x -> (long) (double) x;\n        }\n        else {\n            throw new PrestoException(INVALID_ARGUMENTS, \"can't create kll sketch from type: \" + type);\n        }\n        sketch = KllItemsSketch.wrap(Memory.wrap(bytes.toByteBuffer(), LITTLE_ENDIAN), parameters.getComparator(), parameters.getSerde());\n    }\n\n    public static boolean isKllHistogramSupportedType(Type type)\n    {\n        try {\n            return isNumericType(type) ||\n                    type instanceof AbstractIntType;\n        }\n        catch (PrestoException e) {\n            return false;\n        }\n    }\n\n    @JsonProperty\n    public Slice getSketch()\n    {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/statistics/KllHistogram.java#L68-L104","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","solutions":["Ensure only supported types (Double/Long-backed) are used for KLL sketch columns when writing statistics, or drop statistics on unsupported columns","Check isKllHistogramSupportedType(type) before enabling KLL histograms for a column","Upgrade Presto to a version supporting the type, or disable the KLL statistics feature that produced the blob"],"exampleFix":"// before\nType columnType = DATE; // KLL sketch written for DATE\n// after\nif (KllHistogram.isKllHistogramSupportedType(columnType)) { /* use KLL */ } else { /* fall back to generic stats */ }","handlingStrategy":"validation","validationCode":"if (!KllHistogram.isKllHistogramSupportedType(columnType)) {\n    throw new IllegalArgumentException(\"KLL histogram not supported for type: \" + columnType);\n}","typeGuard":"boolean kllSupported(Type t) { return KllHistogram.isKllHistogramSupportedType(t); }","tryCatchPattern":"try {\n    KllHistogram h = new KllHistogram(serde, bytes, type);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"INVALID_ARGUMENTS\")) {\n        log.warn(\"Skipping unsupported KLL statistics for \" + type);\n        return Optional.empty();\n    }\n    throw e;\n}","preventionTips":["Gate KLL usage on isKllHistogramSupportedType before writing/reading statistics","Avoid generating KLL sketches for non-Double/Long columns at write time","Validate statistics metadata from external writers before consuming"],"tags":["iceberg","statistics","kll-sketch"],"backgroundTag":"unsupported-sketch-type","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"}