prestodb/presto · error · IllegalArgumentException

Unsupported stream kind:

Error message

Unsupported stream kind: 

What it means

OrcMetadataWriter.toStreamKind() converts internal StreamKind values into ORC protobuf Stream.Kind during stream serialization. A StreamKind with no switch case causes IllegalArgumentException("Unsupported stream kind: ..."). This is an exhaustiveness check so unknown internal stream kinds never silently serialize.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/metadata/OrcMetadataWriter.java:342

    private static OrcProto.Stream.Kind toStreamKind(StreamKind streamKind)
    {
        switch (streamKind) {
            case PRESENT:
                return OrcProto.Stream.Kind.PRESENT;
            case DATA:
                return OrcProto.Stream.Kind.DATA;
            case LENGTH:
                return OrcProto.Stream.Kind.LENGTH;
            case DICTIONARY_DATA:
                return OrcProto.Stream.Kind.DICTIONARY_DATA;
            case DICTIONARY_COUNT:
                return OrcProto.Stream.Kind.DICTIONARY_COUNT;
            case SECONDARY:
                return OrcProto.Stream.Kind.SECONDARY;
            case ROW_INDEX:
                return OrcProto.Stream.Kind.ROW_INDEX;
        }
        throw new IllegalArgumentException("Unsupported stream kind: " + streamKind);
    }

    private static OrcProto.ColumnEncoding toColumnEncoding(ColumnEncoding columnEncodings)
    {
        checkArgument(
                !columnEncodings.getAdditionalSequenceEncodings().isPresent(),
                "Writing columns with non-zero sequence IDs is not supported in ORC: " + columnEncodings);

        return OrcProto.ColumnEncoding.newBuilder()
                .setKind(toColumnEncoding(columnEncodings.getColumnEncodingKind()))
                .setDictionarySize(columnEncodings.getDictionarySize())
                .build();
    }

    private static OrcProto.ColumnEncoding.Kind toColumnEncoding(ColumnEncodingKind columnEncodingKind)
    {
        switch (columnEncodingKind) {
            case DIRECT:

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Upgrade presto-orc so all internal StreamKind values map to protobuf kinds
  2. Identify the stream kind from the message and add the missing mapping if maintaining a fork
  3. Avoid writer code paths that emit the unsupported stream kind

Example fix

// before
throw new IllegalArgumentException("Unsupported stream kind: " + streamKind);
// after
case BLOOM_FILTER_UTF8:
    return OrcProto.Stream.Kind.BLOOM_FILTER_UTF8; // add missing mapping
Defensive patterns

Strategy: try-catch

Try / catch

try {
    orcWriter.close();
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unsupported stream kind:")) {
        log.error("ORC writer emitted an unmapped stream kind; upgrade presto-orc", e);
        throw new IOException("ORC stream kind not supported by this writer version", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Writing a stream whose StreamKind falls through the switch in toStream(), e.g. a new stream kind introduced internally but not mapped.

Common situations: Writer internals out of sync with the protobuf schema; forks/custom ORC writers adding stream kinds; version skew after an upgrade.

Related errors


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