{"record":{"id":"8c7d473267c25d6b","repo":"prestodb/presto","slug":"hive-writer-open-error","errorCode":"HIVE_WRITER_OPEN_ERROR","errorMessage":"Error creating %s file. %s","messagePattern":"Error creating (.+?) file\\. (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/OrcFileWriterFactory.java","lineNumber":295,"sourceCode":"            return Optional.of(new OrcFileWriter(\n                    dataSink,\n                    rollbackAction,\n                    orcEncoding,\n                    fileColumnNames,\n                    fileColumnTypes,\n                    compression,\n                    orcWriterOptions,\n                    fileInputColumnIndexes,\n                    metadata.build(),\n                    session.getSqlFunctionProperties().isLegacyTimestamp() ? hiveStorageTimeZone : UTC,\n                    validationInputFactory,\n                    getOrcOptimizedWriterValidateMode(session),\n                    stats,\n                    dwrfEncryptionProvider,\n                    dwrfWriterEncryption));\n        }\n        catch (IOException e) {\n            throw new PrestoException(HIVE_WRITER_OPEN_ERROR, \"Error creating \" + orcEncoding + \" file. \" + e.getMessage(), e);\n        }\n    }\n\n    @VisibleForTesting\n    OrcWriterOptions buildOrcWriterOptions(ConnectorSession session, Properties schema)\n    {\n        boolean mapStatisticsEnabled = isMapStatisticsEnabled(schema);\n        int flatMapKeyLimit = getFlatMapKeyLimit(schema);\n        Set<Integer> flattenedColumns = getFlattenedColumns(schema, session);\n\n        return orcFileWriterConfig\n                .toOrcWriterOptionsBuilder()\n                .withFlushPolicy(DefaultOrcWriterFlushPolicy.builder()\n                        .withStripeMinSize(getOrcOptimizedWriterMinStripeSize(session))\n                        .withStripeMaxSize(getOrcOptimizedWriterMaxStripeSize(session))\n                        .withStripeMaxRowCount(getOrcOptimizedWriterMaxStripeRows(session))\n                        .build())\n                .withDictionaryMaxMemory(getOrcOptimizedWriterMaxDictionaryMemory(session))","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/OrcFileWriterFactory.java#L277-L313","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify destination is writable before running the write\nhdfs dfs -test -w /user/presto/staging && echo OK\n// or for S3: s3api put-object --bucket target --key write-test --body /dev/null","typeGuard":null,"tryCatchPattern":"try {\n    insertInto(orcTable, data);\n} catch (PrestoException e) {\n    if (\"HIVE_WRITER_OPEN_ERROR\".equals(e.getErrorCode().getName())) {\n        fixStorageAccess(e.getCause()); // permissions/credentials/quota\n        return retry(insertInto, attempts = 2);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["hive","orc","io","writer-open","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}