prestodb/presto · error · PrestoException
INVALID_ARGUMENTS
INVALID_ARGUMENTS
Error message
does not support comparisons or ordering
What it means
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.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/sketch/kll/KllSketchAggregationState.java:270
static long getEstimatedKllInMemorySize(@Nullable KllItemsSketch<?> sketch, Class<?> type)
{
if (sketch == null) {
return 0;
}
double[] parameters = SIZE_ESTIMATOR_PARAMETERS.get(type);
if (parameters == null) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "unsupported parameter class: " + type.getName());
}
double linear = parameters[1];
double constant = parameters[0];
return (long) ((linear * sketch.getSerializedSizeBytes()) + constant);
}
static SketchParameters<?> getSketchParameters(Type type)
{
if (!type.isOrderable() || !type.isComparable()) {
throw new PrestoException(INVALID_ARGUMENTS, type + " does not support comparisons or ordering");
}
if (type.equals(REAL)) {
return new SketchParameters<>(Double::compareTo, new ArrayOfDoublesSerDe(),
(Object intValue) -> (double) Float.intBitsToFloat(((Long) intValue).intValue()));
}
else if (type.equals(DOUBLE)) {
return new SketchParameters<>(Double::compareTo, new ArrayOfDoublesSerDe());
}
else if (type.equals(BOOLEAN)) {
return new SketchParameters<>(Boolean::compareTo, new ArrayOfBooleansSerDe());
}
else if (type.equals(TIMESTAMP_WITH_TIME_ZONE) || type.equals(TIME_WITH_TIME_ZONE)) {
return new SketchParameters<>(Long::compareTo, new ArrayOfLongsSerDe(), (Object packed) -> unpackMillisUtc((Long) packed));
}
else if (type.equals(TINYINT) ||
type.equals(SMALLINT) ||
type.equals(INTEGER) ||View on GitHub (pinned to 55bb57d202)
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
Example fix
// before SELECT kll_sketch_agg(map_col) // after SELECT kll_sketch_agg(CAST(element_at(map_col, 'k') AS DOUBLE))
Defensive patterns
Strategy: validation
Validate before calling
boolean canSketch(Type t) { return t.isOrderable() && t.isComparable(); }
// check before issuing KLL aggregation on column of type t Type guard
boolean sk acceptable = type.isOrderable() && type.isComparable();
Try / catch
try { run(sql); } catch (PrestoException e) { if (e.getMessage().contains("does not support comparisons")) { rewriteWithCastAndRetry(); } else throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Trying quantile sketches on nested or non-orderable columns; schema evolution changing a column to a non-comparable type.
Related errors
- CHAR length scale must be in range [0, %s]
- Enum definition expected, got %s
- DECIMAL precision must be in range [1, 38]
- DECIMAL scale must be in range [0, precision]
- INVALID_FUNCTION_ARGUMENT
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/865b7550cf681e13.
Report an issue: GitHub.