prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

%s

What it means

SingleTypedHistogram (the non-grouped histogram implementation) probes its hash table comparing stored keys with the incoming value via type.equalTo. When the key type's equality is unimplemented for the values involved it throws NotSupportedException, which add() wraps in a PrestoException with NOT_SUPPORTED so the query fails with a clear message and cause.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/histogram/SingleTypedHistogram.java:145

    @Override
    public void add(int position, Block block, long count)
    {
        int hashPosition = getBucketId(TypeUtils.hashPosition(type, block, position), mask);

        // look for an empty slot or a slot containing this key
        while (true) {
            if (hashPositions.get(hashPosition) == -1) {
                break;
            }

            try {
                if (type.equalTo(block, position, values, hashPositions.get(hashPosition))) {
                    counts.add(hashPositions.get(hashPosition), count);
                    return;
                }
            }
            catch (NotSupportedException e) {
                throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
            }

            // increment position and mask to handle wrap around
            hashPosition = (hashPosition + 1) & mask;
        }

        addNewGroup(hashPosition, position, block, count);
    }

    @Override
    public Type getType()
    {
        return type;
    }

    @Override
    public int getExpectedSize()
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Cast the key to a supported primitive type before histogram (e.g. CAST(... AS VARCHAR) or json_format for JSON).
  2. Restrict histogram usage to types with defined equality.
  3. Upgrade Presto if equality for the type was added later.

Example fix

// before
SELECT histogram(map_col) FROM t;
// after
SELECT histogram(json_format(CAST(map_col AS JSON))) FROM t;
Defensive patterns

Strategy: type-guard

Validate before calling

-- ensure the histogram key type supports equality
SELECT typeof(x) FROM t LIMIT 1; -- use primitive types only

Type guard

boolean histogramKeySupported(Type t) { return !(t instanceof RowType || t instanceof MapType || t instanceof ArrayType); }

Try / catch

try { hist.add(block, position); } catch (PrestoException e) { if (e.getErrorCode().getName().equals("NOT_SUPPORTED")) { /* convert key to supported type (e.g. json_format) */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling histogram(x) (single-group path, invoked directly or via addAll) with a key type whose equalTo is not supported for the supplied values — e.g. certain complex/nested types.

Common situations: Histogramming rows, maps, or other types lacking full equality support; type support differences across Presto versions.

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


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