prestodb/presto · error · PrestoException
HIVE_WRITER_OPEN_ERROR
HIVE_WRITER_OPEN_ERROR
Error message
Error creating %s file. %s
What it means
OrcFileWriterFactory.createFileWriter opens the target file and constructs an OrcWriter for ORC or DWRF encoding. Any IOException during file creation/ writer construction (before writing rows) is wrapped in HIVE_WRITER_OPEN_ERROR with 'Error creating <encoding> file'. It signals the output file could not be opened for writing.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/OrcFileWriterFactory.java:295
return Optional.of(new OrcFileWriter(
dataSink,
rollbackAction,
orcEncoding,
fileColumnNames,
fileColumnTypes,
compression,
orcWriterOptions,
fileInputColumnIndexes,
metadata.build(),
session.getSqlFunctionProperties().isLegacyTimestamp() ? hiveStorageTimeZone : UTC,
validationInputFactory,
getOrcOptimizedWriterValidateMode(session),
stats,
dwrfEncryptionProvider,
dwrfWriterEncryption));
}
catch (IOException e) {
throw new PrestoException(HIVE_WRITER_OPEN_ERROR, "Error creating " + orcEncoding + " file. " + e.getMessage(), e);
}
}
@VisibleForTesting
OrcWriterOptions buildOrcWriterOptions(ConnectorSession session, Properties schema)
{
boolean mapStatisticsEnabled = isMapStatisticsEnabled(schema);
int flatMapKeyLimit = getFlatMapKeyLimit(schema);
Set<Integer> flattenedColumns = getFlattenedColumns(schema, session);
return orcFileWriterConfig
.toOrcWriterOptionsBuilder()
.withFlushPolicy(DefaultOrcWriterFlushPolicy.builder()
.withStripeMinSize(getOrcOptimizedWriterMinStripeSize(session))
.withStripeMaxSize(getOrcOptimizedWriterMaxStripeSize(session))
.withStripeMaxRowCount(getOrcOptimizedWriterMaxStripeRows(session))
.build())
.withDictionaryMaxMemory(getOrcOptimizedWriterMaxDictionaryMemory(session))View on GitHub (pinned to 55bb57d202)
Solutions
- Fix the underlying IOException cause shown in the message (permissions, quota, connectivity) and retry the write.
- Verify the staging directory (hive temp/staging path) exists and is writable by the Presto user.
- Check S3/HDFS configuration (credentials, endpoint, bucket existence) if writing to object storage.
- Review orc_writer_* session properties and table ORC options for invalid values that break writer construction.
Defensive patterns
Strategy: validation
Validate before calling
// Verify destination is writable before running the write hdfs dfs -test -w /user/presto/staging && echo OK // or for S3: s3api put-object --bucket target --key write-test --body /dev/null
Try / catch
try {
insertInto(orcTable, data);
} catch (PrestoException e) {
if ("HIVE_WRITER_OPEN_ERROR".equals(e.getErrorCode().getName())) {
fixStorageAccess(e.getCause()); // permissions/credentials/quota
return retry(insertInto, attempts = 2);
}
throw e;
} Prevention
- Verify staging directory existence and permissions before writes.
- Validate S3/HDFS credentials and connectivity in deployment health checks.
- Keep ORC session properties within documented, tested values.
When it happens
Trigger: createFileWriter when new OrcWriter(...) or the underlying filesystem output stream creation throws IOException — e.g. cannot create the file at the staging path, or the writer fails on first open.
Common situations: Missing write permission on the staging/target directory, HDFS not available or in safe mode, S3 bucket/credential misconfiguration, disk full, or invalid ORC writer options derived from session properties.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- HIVE_FILESYSTEM_ERROR
- HIVE_FILESYSTEM_ERROR
- HIVE_FILESYSTEM_ERROR
- HIVE_WRITER_CLOSE_ERROR
- HIVE_WRITER_CLOSE_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/8c7d473267c25d6b.
Report an issue: GitHub.