prestodb/presto · error · IllegalArgumentException

Unsupported type:

Error message

Unsupported type: 

What it means

SelectiveStreamReaders.createStreamReader builds selective readers per ORC type kind. UNION types have no selective reader implementation and every unrecognized kind falls into the default branch, which throws IllegalArgumentException. It means the requested type is not supported by the selective reader path.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/SelectiveStreamReaders.java:134

                return new ListSelectiveStreamReader(streamDescriptor, filters, requiredSubfields, null, 0, outputType, options, systemMemoryContext, isLowMemory);
            case STRUCT:
                verifyStreamType(streamDescriptor, outputType, RowType.class::isInstance);
                return new StructSelectiveStreamReader(streamDescriptor, filters, requiredSubfields, outputType, options, systemMemoryContext, isLowMemory);
            case MAP:
                verifyStreamType(streamDescriptor, outputType, MapType.class::isInstance);
                return new MapSelectiveStreamReader(streamDescriptor, filters, requiredSubfields, outputType, options, systemMemoryContext, isLowMemory);
            case DECIMAL: {
                verifyStreamType(streamDescriptor, outputType, DecimalType.class::isInstance);
                if (streamDescriptor.getOrcType().getPrecision().get() <= MAX_SHORT_PRECISION) {
                    return new ShortDecimalSelectiveStreamReader(streamDescriptor, getOptionalOnlyFilter(type, filters), outputType, systemMemoryContext.newOrcLocalMemoryContext(SelectiveStreamReaders.class.getSimpleName()));
                }
                else {
                    return new LongDecimalSelectiveStreamReader(streamDescriptor, getOptionalOnlyFilter(type, filters), outputType, systemMemoryContext.newOrcLocalMemoryContext(SelectiveStreamReaders.class.getSimpleName()));
                }
            }
            case UNION:
            default:
                throw new IllegalArgumentException("Unsupported type: " + type);
        }
    }

    private static void verifyStreamType(StreamDescriptor streamDescriptor, Optional<Type> outputType, Predicate<Type> predicate)
    {
        if (outputType.isPresent()) {
            ReaderUtils.verifyStreamType(streamDescriptor, outputType.get(), predicate);
        }
    }

    private static Optional<TupleDomainFilter> getOptionalOnlyFilter(OrcTypeKind type, Map<Subfield, TupleDomainFilter> filters)
    {
        if (filters.isEmpty()) {
            return Optional.empty();
        }

        checkArgument(filters.size() == 1, format("Stream reader for %s doesn't support multiple range filters", type));
        return Optional.of(Iterables.getOnlyElement(filters.values()));

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Avoid UNION columns or cast them to a supported type in the table definition
  2. Rewrite the data replacing unions with structs or nullable columns
  3. Disable the selective reader path so the column uses the legacy reader
  4. Upgrade Presto if union support has been added

Example fix

// before
throw new IllegalArgumentException("Unsupported type: " + type);
// after
if (type == UNION) { return new UnionBatchStreamReader(descriptor, ...); } // or reject earlier in planning
Defensive patterns

Strategy: validation

Validate before calling

if (type == OrcTypeKind.UNION) { throw new UnsupportedTypeException("UNION columns are not supported by the selective reader"); }

Type guard

boolean hasSelectiveReader(OrcTypeKind t) { return t != UNION && t != null; }

Try / catch

try { reader = SelectiveStreamReaders.createStreamReader(descriptor, ...); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported type")) { reader = legacyStreamReaders.createStreamReader(descriptor, ...); } else throw e; }

Prevention

When it happens

Trigger: Calling createStreamReader for a column whose ORC type kind is UNION (or any kind not handled by an explicit case), often reached from createNestedStreamReader for nested union columns.

Common situations: Reading Hive/ORC tables containing uniontype columns with selective reader enabled; nested union fields under structs/maps in subfield-pruned reads.

Related errors


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