{"record":{"id":"62a3c2b3a633946b","repo":"prestodb/presto","slug":"hive-cannot-open-split","errorCode":"HIVE_CANNOT_OPEN_SPLIT","errorMessage":"Error opening Hive split %s (offset=%s, length=%s) using %s: %s","messagePattern":"Error opening Hive split (.+?) \\(offset=(.+?), length=(.+?)\\) using (.+?): (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveUtil.java","lineNumber":323,"sourceCode":"            int headerCount = getHeaderCount(schema);\n            //  Only skip header rows when the split is at the beginning of the file\n            if (start == 0 && headerCount > 0) {\n                Utilities.skipHeader(recordReader, headerCount, recordReader.createKey(), recordReader.createValue());\n            }\n\n            int footerCount = getFooterCount(schema);\n            if (footerCount > 0) {\n                recordReader = new FooterAwareRecordReader<>(recordReader, footerCount, jobConf);\n            }\n\n            return recordReader;\n        }\n        catch (IOException e) {\n            if (e instanceof TextLineLengthLimitExceededException) {\n                throw new PrestoException(HIVE_BAD_DATA, \"Line too long in text file: \" + path, e);\n            }\n\n            throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, format(\"Error opening Hive split %s (offset=%s, length=%s) using %s: %s\",\n                    path,\n                    start,\n                    length,\n                    getInputFormatName(schema),\n                    firstNonNull(e.getMessage(), e.getClass().getName())),\n                    e);\n        }\n    }\n\n    public static void setReadColumns(Configuration configuration, List<Integer> readHiveColumnIndexes)\n    {\n        configuration.set(READ_COLUMN_IDS_CONF_STR, Joiner.on(',').join(readHiveColumnIndexes));\n        configuration.setBoolean(READ_ALL_COLUMNS, false);\n    }\n\n    public static Optional<CompressionCodec> getCompressionCodec(TextInputFormat inputFormat, Path file)\n    {\n        CompressionCodecFactory compressionCodecFactory;","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveUtil.java#L305-L341","documentation":"A generic failure while opening a Hive split's input format: any IOException from createRecordReader that is not the line-length case is wrapped as HIVE_CANNOT_OPEN_SPLIT, including the split path, offset, length, input format class, and underlying message. It means the connector could not instantiate or initialize the record reader for that split.","triggerScenarios":"Opening a split whose file is missing/corrupt, wrong compression extension vs actual codec, input format class fails to initialize (misconfigured JobConf, permission denied, truncated file, checksum mismatch).","commonSituations":"Files deleted or moved by compaction while a query reads them; corrupt/truncated files on HDFS/S3; input format configuration errors; S3 permission or throttling issues; mismatched codec extensions (.gz file not gzipped).","solutions":["Verify the file exists and is readable at the reported path (hdfs dfs -ls / aws s3 ls) and check its integrity","Confirm the file's actual compression matches its extension/format declared by the table","Re-run the query — transient S3/HDFS errors may resolve; otherwise restore/reproduce the data","Check the wrapped cause message and the input format name in the error for the true root cause"],"exampleFix":"// before\nCREATE TABLE t (x bigint) WITH (format='TEXTFILE', external_location='s3://bucket/parts') -- files named .gz but not gzip-compressed\n// after\nrecompress files properly or drop the .gz suffix and set format/compression accordingly","handlingStrategy":"retry","validationCode":"if (!fileExists(path) || !isReadable(path)) throw new IllegalStateException(\"split file missing/unreadable: \" + path);","typeGuard":null,"tryCatchPattern":"try { readSplit(split); } catch (PrestoException e) { if (e.getErrorCode().getCode() == StandardErrorCode.HIVE_CANNOT_OPEN_SPLIT.getCode()) { log.warn(\"split open failed for {} offset {}\", path, offset); /* retry with backoff, then fail with wrapped cause */ } else throw e; }","preventionTips":["Ensure table input format/compression declared in metadata matches actual files","Avoid reading while compaction/ETL rewrites files; use consistent snapshots","Keep S3/HDFS permissions and network paths healthy; monitor for truncated uploads"],"tags":["hive","split","io","input-format","file-access"],"backgroundTag":"hive-split-open-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"}