prestodb/presto · error · PrestoException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
GroupedKHyperLogLogState number of groups exceed limit %d set by khyperloglog-agg-group-limit
What it means
KHyperLogLog aggregations that group results into a GroupedKHyperLogLogState enforce a maximum number of distinct groups via the khyperloglog-agg-group-limit config. When the aggregation needs more groups than this limit, ensureCapacity throws NOT_SUPPORTED to bound memory use.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/type/khyperloglog/KHyperLogLogStateFactory.java:90
private long size;
private final long groupLimit;
public GroupedKHyperLogLogState(long groupLimit)
{
this.groupLimit = groupLimit;
}
@Override
public void setGroupId(long groupId)
{
this.groupId = groupId;
}
@Override
public void ensureCapacity(long size)
{
if (groupLimit > 0 && size > groupLimit) {
throw new PrestoException(NOT_SUPPORTED, format("GroupedKHyperLogLogState number of groups exceed limit %d set by khyperloglog-agg-group-limit", groupLimit));
}
khlls.ensureCapacity(size);
}
@Override
public KHyperLogLog getKHLL()
{
return khlls.get(groupId);
}
@Override
public void setKHLL(KHyperLogLog value)
{
if (getKHLL() != null) {
size -= getKHLL().estimatedInMemorySize();
}
size += value.estimatedInMemorySize();
khlls.set(groupId, value);View on GitHub (pinned to 55bb57d202)
Solutions
- Increase khyperloglog-agg-group-limit in the cluster configuration (or session property) to cover expected group cardinality.
- Reduce cardinality of the GROUP BY key (coarser buckets, bucketing, pre-aggregation).
- Split the query into batches or filter the input so groups stay under the limit.
Example fix
// before (config.properties) khyperloglog-agg-group-limit=10000 // after khyperloglog-agg-group-limit=1000000
Defensive patterns
Strategy: try-catch
Validate before calling
// Before running the query, check expected group cardinality against the limit:
long distinctGroups = execute("SELECT approx_distinct(group_col) FROM src").getLong(0);
long limit = getSessionProperty("khyperloglog-agg-group-limit");
boolean safe = distinctGroups <= limit; Try / catch
try (QueryResult r = runQuery(khllQuery)) {
// process results
} catch (PrestoException e) {
if (e.getErrorCode() == NOT_SUPPORTED.toErrorCode() &&
e.getMessage().contains("khyperloglog-agg-group-limit")) {
// raise the limit (SET SESSION khyperloglog_agg_group_limit = ...) and retry, or reduce group cardinality
} else {
throw e;
}
} Prevention
- Set khyperloglog-agg-group-limit to comfortably exceed the max expected distinct group count.
- Estimate group cardinality with approx_distinct before running KHLL aggregations.
- Reduce GROUP BY cardinality (bucketing, coarser keys) for high-cardinality columns.
- Prefer plain approx_distinct over khyperloglog_agg when per-group sketches are not needed.
When it happens
Trigger: Running a KHyperLogLog aggregate (khyperloglog_agg) with GROUP BY where the number of distinct group keys exceeds the configured khyperloglog-agg-group-limit at runtime.
Common situations: High-cardinality grouping columns (user IDs, URLs) with a cluster configured with a small conservative group limit; queries that worked on samples but explode on full data.
Understand the failure class
Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.
Related errors
- GENERIC_INSUFFICIENT_RESOURCES
- INVALID_FUNCTION_ARGUMENT
- ACCUMULO_TABLE_EXISTS
- NOT_SUPPORTED
- ARROW_INTERNAL_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/dd545acf98eee57c.
Report an issue: GitHub.