{"record":{"id":"ed08172436482789","repo":"prestodb/presto","slug":"unsupported-type-ed0817","errorCode":null,"errorMessage":"Unsupported type: ","messagePattern":"Unsupported type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/AbstractLongSelectiveStreamReader.java","lineNumber":145,"sourceCode":"\n        if (outputType == SMALLINT) {\n            if (!shortValuesPopulated || positionCount < outputPositionCount) {\n                if (positionCount < outputPositionCount) {\n                    compactValues(positions, positionCount, includeNulls);\n                }\n                if (shortValues == null || shortValues.length < positionCount) {\n                    shortValues = new short[positionCount];\n                }\n                for (int i = 0; i < positionCount; i++) {\n                    shortValues[i] = (short) values[i];\n                }\n                shortValuesPopulated = true;\n            }\n\n            return newLease(new ShortArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), shortValues));\n        }\n\n        throw new UnsupportedOperationException(\"Unsupported type: \" + outputType);\n    }\n\n    private BlockLease newLease(Block block)\n    {\n        valuesInUse = true;\n        return ClosingBlockLease.newLease(block, () -> valuesInUse = false);\n    }\n\n    protected Block buildOutputBlock(int[] positions, int positionCount, boolean includeNulls)\n    {\n        checkState(!valuesInUse, \"BlockLease hasn't been closed yet\");\n\n        Type outputType = context.getOutputType();\n        if (outputType == BIGINT) {\n            return getLongArrayBlock(positions, positionCount, includeNulls);\n        }\n\n        if (outputType == INTEGER || outputType == DATE) {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/AbstractLongSelectiveStreamReader.java#L127-L163","documentation":"AbstractLongSelectiveStreamReader.buildOutputBlockView() materializes output blocks for long-based stream readers. The reader supports BIGINT/INTEGER/DATE/TIME/SIZE/etc. (long) and SMALLINT (short) views; any other outputType reaches UnsupportedOperationException(\"Unsupported type: ...\"). It prevents producing wrongly-typed blocks from a long-decoded stream.","triggerScenarios":"Requesting a selective read whose requested outputType is not one of the long-compatible types handled in buildOutputBlockView(), e.g. asking this long reader for BOOLEAN/VARCHAR output.","commonSituations":"Reader/output type mismatch from projection or type coercion bugs; custom readers reusing AbstractLongSelectiveStreamReader for incompatible types; Presto engine/reader version skew.","solutions":["Ensure the reader's declared ORC type supports the requested outputType; use the correct stream reader class","Coerce the requested output type to a supported one (e.g. BIGINT) in the reading plan","Upgrade presto-orc if the outputType should be supported by this reader"],"exampleFix":"// before\nSelectiveStreamReader r = new LongSelectiveStreamReader(...); block = r.getBlockView(outputType = BOOLEAN); // throws\n// after\ncheckArgument(outputType == BIGINT || outputType == INTEGER || outputType == SMALLINT, \"Long reader cannot output %s\", outputType);","handlingStrategy":"type-guard","validationCode":"// Before constructing/reading, confirm the output type is long-compatible\nprivate static final Set<Type> SUPPORTED_LONG_OUTPUTS = Set.of(BIGINT, INTEGER, DATE, TIME, SMALLINT /* as short path */);\ncheckArgument(outputType.getJavaType() == long.class || outputType.getJavaType() == short.class, \"Output type %s not supported by long reader\", outputType);","typeGuard":"boolean isLongReadableOutput(Type t) {\n    return t.getJavaType() == long.class || t == SMALLINT;\n}","tryCatchPattern":"try {\n    return reader.getBlockView(positions, positionCount, includeNulls);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unsupported type:\")) {\n        throw new IllegalStateException(\"Long stream reader cannot output \" + outputType + \"; use the matching reader\", e);\n    }\n    throw e;\n}","preventionTips":["Match stream reader class to the requested output type","Add assertions in plans that long readers only project integral/date/time types","Test selective readers per output type in CI"],"tags":["orc","selective-reader","type-mismatch","reader"],"backgroundTag":"unsupported-output-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"}