prestodb/presto · error · OrcCorruptionException
Can not read SQL type %s from ORC stream %s of type %s
Error message
Can not read SQL type %s from ORC stream %s of type %s
What it means
ReaderUtils.verifyStreamType validates that an ORC stream's actual SQL type is acceptable for the reader being constructed. If the predicate fails it throws OrcCorruptionException describing the SQL type, stream name, and ORC type kind. It guards against schema mismatches between the declared table schema and the file's stored types.
Source
Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/ReaderUtils.java:35
import com.facebook.presto.orc.OrcCorruptionException;
import com.facebook.presto.orc.StreamDescriptor;
import java.util.function.Predicate;
import static java.lang.Math.max;
final class ReaderUtils
{
private ReaderUtils() {}
public static void verifyStreamType(StreamDescriptor streamDescriptor, Type actual, Predicate<Type> validTypes)
throws OrcCorruptionException
{
if (validTypes.test(actual)) {
return;
}
throw new OrcCorruptionException(
streamDescriptor.getOrcDataSourceId(),
"Can not read SQL type %s from ORC stream %s of type %s",
actual,
streamDescriptor.getStreamName(),
streamDescriptor.getOrcTypeKind());
}
public static int minNonNullValueSize(int nonNullCount)
{
return max(nonNullCount + 1, 1025);
}
public static byte[] unpackByteNulls(byte[] values, boolean[] isNull)
{
byte[] result = new byte[isNull.length];
int position = 0;
for (int i = 0; i < isNull.length; i++) {View on GitHub (pinned to 55bb57d202)
Solutions
- Align the table schema with the actual ORC file column types
- Regenerate the file with the expected types
- Use the correct reader for the stream's ORC type kind
- Run a schema/footighter validation (e.g., ORC metadata dump) before querying
Example fix
// before: mismatch at read time ReaderUtils.verifyStreamType(descriptor, Optional.of(BIGINT), type -> type.equals(BIGINT)); // after: confirm schema first checkState(actualOrcType == INT_OR_LONG, "Column %s must be an integer type in the file", columnName);
Defensive patterns
Strategy: validation
Validate before calling
Type actual = fileColumnTypes.get(columnName); if (outputType.isPresent() && !Objects.equals(actual, outputType.get())) { throw new SchemaMismatchException(columnName, actual, outputType.get()); } Type guard
boolean schemaMatches(Type file, Type expected) { return expected.equals(file); } Try / catch
try { verifyStreamType(descriptor, outputType, predicate); } catch (OrcCorruptionException e) { throw new SchemaMismatchException("File type does not match declared schema: " + e.getMessage(), e); } Prevention
- Refresh table schema after any writer-side type changes
- Diff file footer types against metastore schema during ingestion
- Avoid ALTER COLUMN changes without rewriting underlying ORC files
- Use ORC metadata tools to dump per-column types before querying
When it happens
Trigger: Constructing a stream reader with an outputType whose SQL type doesn't match the ORC stream's type (e.g., reading a VARCHAR column as BIGINT, or a map column where a scalar is expected).
Common situations: Stale table schema after the underlying file format changed; Hive Metastore schema mismatch with file contents; reading files written with different column types than declared.
Related errors
- Decoded value out of range for a 32bit number
- Decoded value out of range for a 16bit number
- HIVE_CURSOR_ERROR
- File has no columns
- Stripe encryption keys are missing, but file is encrypted
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/10e09afb0182dba9.
Report an issue: GitHub.