prestodb/presto · error · PrestoException
KAFKA_SCHEMA_ERROR
KAFKA_SCHEMA_ERROR
Error message
Unable to read data schema at '%s'
What it means
getDataSchema reads the table's configured dataSchemaLocation from local disk; if Files.readAllBytes throws IOException (missing file, permissions, path is a directory), the connector wraps it in a PrestoException with code KAFKA_SCHEMA_ERROR. The connector cannot build the Avro data schema needed to encode/decode records.
Source
Thrown at presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaPageSinkProvider.java:110
return new KafkaPageSink(
handle.getSchemaName(),
handle.getTopicName(),
handle.getColumns(),
keyEncoder,
messageEncoder,
producerFactory,
kafkaClusterMetadataSupplier);
}
private Optional<String> getDataSchema(Optional<String> dataSchemaLocation)
{
return dataSchemaLocation.map(location -> {
try {
return new String(Files.readAllBytes(Paths.get(location)));
}
catch (IOException e) {
throw new PrestoException(KAFKA_SCHEMA_ERROR, format("Unable to read data schema at '%s'", dataSchemaLocation.get()), e);
}
});
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Verify the file exists and is readable on every node that runs the query: ls -l <dataSchemaLocation>
- Use a URI-based (hdfs/http) schema location or ship the schema inside the table description JSON instead of a local file path
- Fix permissions/ownership of the schema file
- Correct the dataSchemaLocation value in the Kafka table description
Example fix
// before (table description)
"dataSchema": "/etc/kafka/schemas/order.avsc"
// after - inline schema or valid path
"dataSchema": {"type":"record","name":"order","fields":[...]} Defensive patterns
Strategy: validation
Validate before calling
java.nio.file.Path p = java.nio.file.Paths.get(dataSchemaLocation);
if (!java.nio.file.Files.isReadable(p))
throw new IllegalStateException("Data schema not readable: " + p); Type guard
null
Try / catch
try { ... } catch (PrestoException e) {
if (KAFKA_SCHEMA_ERROR.toErrorCode().getCode().equals(e.getErrorCode().getCode())) {
// fix/verify dataSchemaLocation, then retry
}
} Prevention
- Use absolute paths valid on all worker nodes
- Prefer inlining the schema in the table description JSON
- Add a deployment check that schema files exist on every worker
- Keep schema files outside ephemeral container layers
When it happens
Trigger: kafka.table-description data schema location (or table's dataSchemaLocation property) points to a file that does not exist or is unreadable at the moment keyEncoder/messageEncoder request the schema.
Common situations: Typo or wrong absolute path in table description JSON; schema file deleted from workers (file only exists on coordinator); permissions after container image change; relative path resolved against a different working directory on a worker node.
Related errors
- Failed to append record
- Failed to close ByteArrayOutputStream
- BIGQUERY_ERROR_END_OF_AVRO_BUFFER
- BIGQUERY_ERROR_READING_NEXT_AVRO_RECORD
- unexpected internal column '%s'
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/33bc5ed9350a09b9.
Report an issue: GitHub.