{"record":{"id":"99b96c0676e491fa","repo":"prestodb/presto","slug":"not-supported-99b96c","errorCode":"NOT_SUPPORTED","errorMessage":"Cannot operate on a t-digest with real numbers","messagePattern":"Cannot operate on a t-digest with real numbers","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigestAggregationFunction.java","lineNumber":204,"sourceCode":"        switch (type) {\n            case TDIGEST:\n                return getTDigestInputMethodHandle(valueType, arity);\n            case QDIGEST:\n                return getQuantileDigestInputMethodHandle(valueType, arity);\n            default:\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"%s must be a statistical digest\", type));\n        }\n    }\n\n    private MethodHandle getTDigestInputMethodHandle(Type valueType, int arity)\n    {\n        final MethodHandle inputFunction;\n        switch (valueType.getDisplayName()) {\n            case StandardTypes.DOUBLE:\n                inputFunction = T_DIGEST_INPUT_DOUBLE;\n                break;\n            case StandardTypes.REAL:\n                throw new PrestoException(NOT_SUPPORTED, \"Cannot operate on a t-digest with real numbers\");\n            case StandardTypes.BIGINT:\n                throw new PrestoException(NOT_SUPPORTED, \"Cannot operate on a t-digest with longs\");\n            default:\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"Unsupported type %s supplied\", valueType.getDisplayName()));\n        }\n        return addArguments(inputFunction, arity, DEFAULT_COMPRESSION);\n    }\n\n    private static MethodHandle getQuantileDigestInputMethodHandle(Type valueType, int arity)\n    {\n        final MethodHandle inputFunction;\n        switch (valueType.getDisplayName()) {\n            case StandardTypes.DOUBLE:\n                inputFunction = QUANTILE_DIGEST_INPUT_DOUBLE;\n                break;\n            case StandardTypes.REAL:\n                inputFunction = INPUT_REAL;\n                break;","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/StatisticalDigestAggregationFunction.java#L186-L222","documentation":"The t-digest implementation only accepts DOUBLE input values. REAL (float) is explicitly rejected with NOT_SUPPORTED rather than silently upcast, because the underlying TDigest method handles are bound only for double.","triggerScenarios":"Creating a t-digest aggregation (tdigest_agg or similar) over a REAL column, which reaches getTDigestInputMethodHandle's REAL case.","commonSituations":"Using float4 columns (e.g. sensor readings) directly with t-digest quantile approximations.","solutions":["CAST the REAL column to DOUBLE before the t-digest aggregation.","Use a q-digest/double aggregation variant that supports REAL if available.","Change the schema to store DOUBLE if t-digest operations are the primary use."],"exampleFix":"// before\nSELECT tdigest_agg(temperature) FROM sensors; -- temperature is REAL\n// after\nSELECT tdigest_agg(CAST(temperature AS DOUBLE)) FROM sensors;","handlingStrategy":"type-guard","validationCode":"-- verify column type before t-digest\nSELECT typeof(temperature) FROM sensors LIMIT 1; -- must be double, not real","typeGuard":"boolean supportsTDigest(Type t) { return t.getDisplayName().equals(\"double\"); }","tryCatchPattern":"try { agg(); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"NOT_SUPPORTED\") && e.getMessage().contains(\"real\")) { castToDoubleAndRetry(); } else throw e; }","preventionTips":["CAST REAL columns to DOUBLE for t-digest use","Prefer DOUBLE column types in schemas used for quantiles","Check function docs for supported input types"],"tags":["aggregation","t-digest","unsupported-type"],"backgroundTag":"unsupported-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"}