prestodb/presto · error · UnsupportedOperationException

Unsupported type:

Error message

Unsupported type: 

What it means

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.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/AbstractLongSelectiveStreamReader.java:145

        if (outputType == SMALLINT) {
            if (!shortValuesPopulated || positionCount < outputPositionCount) {
                if (positionCount < outputPositionCount) {
                    compactValues(positions, positionCount, includeNulls);
                }
                if (shortValues == null || shortValues.length < positionCount) {
                    shortValues = new short[positionCount];
                }
                for (int i = 0; i < positionCount; i++) {
                    shortValues[i] = (short) values[i];
                }
                shortValuesPopulated = true;
            }

            return newLease(new ShortArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), shortValues));
        }

        throw new UnsupportedOperationException("Unsupported type: " + outputType);
    }

    private BlockLease newLease(Block block)
    {
        valuesInUse = true;
        return ClosingBlockLease.newLease(block, () -> valuesInUse = false);
    }

    protected Block buildOutputBlock(int[] positions, int positionCount, boolean includeNulls)
    {
        checkState(!valuesInUse, "BlockLease hasn't been closed yet");

        Type outputType = context.getOutputType();
        if (outputType == BIGINT) {
            return getLongArrayBlock(positions, positionCount, includeNulls);
        }

        if (outputType == INTEGER || outputType == DATE) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Ensure the reader's declared ORC type supports the requested outputType; use the correct stream reader class
  2. Coerce the requested output type to a supported one (e.g. BIGINT) in the reading plan
  3. Upgrade presto-orc if the outputType should be supported by this reader

Example fix

// before
SelectiveStreamReader r = new LongSelectiveStreamReader(...); block = r.getBlockView(outputType = BOOLEAN); // throws
// after
checkArgument(outputType == BIGINT || outputType == INTEGER || outputType == SMALLINT, "Long reader cannot output %s", outputType);
Defensive patterns

Strategy: type-guard

Validate before calling

// Before constructing/reading, confirm the output type is long-compatible
private static final Set<Type> SUPPORTED_LONG_OUTPUTS = Set.of(BIGINT, INTEGER, DATE, TIME, SMALLINT /* as short path */);
checkArgument(outputType.getJavaType() == long.class || outputType.getJavaType() == short.class, "Output type %s not supported by long reader", outputType);

Type guard

boolean isLongReadableOutput(Type t) {
    return t.getJavaType() == long.class || t == SMALLINT;
}

Try / catch

try {
    return reader.getBlockView(positions, positionCount, includeNulls);
} catch (UnsupportedOperationException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unsupported type:")) {
        throw new IllegalStateException("Long stream reader cannot output " + outputType + "; use the matching reader", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Reader/output type mismatch from projection or type coercion bugs; custom readers reusing AbstractLongSelectiveStreamReader for incompatible types; Presto engine/reader version skew.

Related errors


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