{"record":{"id":"865b7550cf681e13","repo":"prestodb/presto","slug":"invalid-arguments-865b75","errorCode":"INVALID_ARGUMENTS","errorMessage":" does not support comparisons or ordering","messagePattern":" does not support comparisons or ordering","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/sketch/kll/KllSketchAggregationState.java","lineNumber":270,"sourceCode":"\n    static long getEstimatedKllInMemorySize(@Nullable KllItemsSketch<?> sketch, Class<?> type)\n    {\n        if (sketch == null) {\n            return 0;\n        }\n        double[] parameters = SIZE_ESTIMATOR_PARAMETERS.get(type);\n        if (parameters == null) {\n            throw new PrestoException(GENERIC_INTERNAL_ERROR, \"unsupported parameter class: \" + type.getName());\n        }\n        double linear = parameters[1];\n        double constant = parameters[0];\n        return (long) ((linear * sketch.getSerializedSizeBytes()) + constant);\n    }\n\n    static SketchParameters<?> getSketchParameters(Type type)\n    {\n        if (!type.isOrderable() || !type.isComparable()) {\n            throw new PrestoException(INVALID_ARGUMENTS, type + \" does not support comparisons or ordering\");\n        }\n\n        if (type.equals(REAL)) {\n            return new SketchParameters<>(Double::compareTo, new ArrayOfDoublesSerDe(),\n                    (Object intValue) -> (double) Float.intBitsToFloat(((Long) intValue).intValue()));\n        }\n        else if (type.equals(DOUBLE)) {\n            return new SketchParameters<>(Double::compareTo, new ArrayOfDoublesSerDe());\n        }\n        else if (type.equals(BOOLEAN)) {\n            return new SketchParameters<>(Boolean::compareTo, new ArrayOfBooleansSerDe());\n        }\n        else if (type.equals(TIMESTAMP_WITH_TIME_ZONE) || type.equals(TIME_WITH_TIME_ZONE)) {\n            return new SketchParameters<>(Long::compareTo, new ArrayOfLongsSerDe(), (Object packed) -> unpackMillisUtc((Long) packed));\n        }\n        else if (type.equals(TINYINT) ||\n                type.equals(SMALLINT) ||\n                type.equals(INTEGER) ||","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/sketch/kll/KllSketchAggregationState.java#L252-L288","documentation":"KllSketchAggregationState.getSketchParameters requires the input type to be both orderable and comparable, since KLL sketches maintain quantiles over an ordered set of values. Types without ordering/comparison support cannot build a comparator, so the library throws INVALID_ARGUMENTS.","triggerScenarios":"Invoking a KLL sketch aggregation on a column type where Type.isOrderable() or Type.isComparable() is false (e.g. MAP, ROW, complex types) as reached via initializeSketch/input.","commonSituations":"Trying quantile sketches on nested or non-orderable columns; schema evolution changing a column to a non-comparable type.","solutions":["Cast or extract an orderable scalar (BIGINT, DOUBLE/REAL, VARCHAR) before sketching","Use an aggregation supporting the type (e.g. map_agg + later numeric sketching)","Change the schema/column to an orderable type"],"exampleFix":"// before\nSELECT kll_sketch_agg(map_col)\n// after\nSELECT kll_sketch_agg(CAST(element_at(map_col, 'k') AS DOUBLE))","handlingStrategy":"validation","validationCode":"boolean canSketch(Type t) { return t.isOrderable() && t.isComparable(); }\n// check before issuing KLL aggregation on column of type t","typeGuard":"boolean sk acceptable = type.isOrderable() && type.isComparable();","tryCatchPattern":"try { run(sql); } catch (PrestoException e) { if (e.getMessage().contains(\"does not support comparisons\")) { rewriteWithCastAndRetry(); } else throw e; }","preventionTips":["Only apply KLL sketch functions to scalar orderable columns","Validate column types in query builders before generating SQL","Extract nested fields to scalars before sketching"],"tags":["presto","sketch","type-system","argument-validation"],"backgroundTag":"non-orderable-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"}