{"record":{"id":"15d25b1a205722c3","repo":"prestodb/presto","slug":"not-supported-15d25b","errorCode":"NOT_SUPPORTED","errorMessage":"%s","messagePattern":"%s","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/histogram/SingleTypedHistogram.java","lineNumber":145,"sourceCode":"    @Override\n    public void add(int position, Block block, long count)\n    {\n        int hashPosition = getBucketId(TypeUtils.hashPosition(type, block, position), mask);\n\n        // look for an empty slot or a slot containing this key\n        while (true) {\n            if (hashPositions.get(hashPosition) == -1) {\n                break;\n            }\n\n            try {\n                if (type.equalTo(block, position, values, hashPositions.get(hashPosition))) {\n                    counts.add(hashPositions.get(hashPosition), count);\n                    return;\n                }\n            }\n            catch (NotSupportedException e) {\n                throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);\n            }\n\n            // increment position and mask to handle wrap around\n            hashPosition = (hashPosition + 1) & mask;\n        }\n\n        addNewGroup(hashPosition, position, block, count);\n    }\n\n    @Override\n    public Type getType()\n    {\n        return type;\n    }\n\n    @Override\n    public int getExpectedSize()\n    {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/histogram/SingleTypedHistogram.java#L127-L163","documentation":"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.","triggerScenarios":"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.","commonSituations":"Histogramming rows, maps, or other types lacking full equality support; type support differences across Presto versions.","solutions":["Cast the key to a supported primitive type before histogram (e.g. CAST(... AS VARCHAR) or json_format for JSON).","Restrict histogram usage to types with defined equality.","Upgrade Presto if equality for the type was added later."],"exampleFix":"// before\nSELECT histogram(map_col) FROM t;\n// after\nSELECT histogram(json_format(CAST(map_col AS JSON))) FROM t;","handlingStrategy":"type-guard","validationCode":"-- ensure the histogram key type supports equality\nSELECT typeof(x) FROM t LIMIT 1; -- use primitive types only","typeGuard":"boolean histogramKeySupported(Type t) { return !(t instanceof RowType || t instanceof MapType || t instanceof ArrayType); }","tryCatchPattern":"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; } }","preventionTips":["Cast complex keys to VARCHAR/JSON before histogram","Prefer single-type, primitive-key histograms","Verify type equality support in the Presto version in use"],"tags":["presto","histogram","not-supported","type-system"],"backgroundTag":"operation-not-supported-for-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"}