{"record":{"id":"a078cab647c47354","repo":"prestodb/presto","slug":"hive-bad-data-a078ca","errorCode":"HIVE_BAD_DATA","errorMessage":"RCFile is empty: ","messagePattern":"RCFile is empty: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/rcfile/RcFilePageSourceFactory.java","lineNumber":124,"sourceCode":"            TupleDomain<HiveColumnHandle> effectivePredicate,\n            DateTimeZone hiveStorageTimeZone,\n            HiveFileContext hiveFileContext,\n            Optional<EncryptionInformation> encryptionInformation,\n            Optional<byte[]> rowIDPartitionComponent)\n    {\n        RcFileEncoding rcFileEncoding;\n        if (LazyBinaryColumnarSerDe.class.getName().equals(storage.getStorageFormat().getSerDe())) {\n            rcFileEncoding = new BinaryRcFileEncoding();\n        }\n        else if (ColumnarSerDe.class.getName().equals(storage.getStorageFormat().getSerDe())) {\n            rcFileEncoding = createTextVectorEncoding(getHiveSchema(storage.getSerdeParameters(), tableParameters), session.getSqlFunctionProperties().isLegacyTimestamp() ? hiveStorageTimeZone : UTC);\n        }\n        else {\n            return Optional.empty();\n        }\n\n        if (fileSplit.getFileSize() == 0) {\n            throw new PrestoException(HIVE_BAD_DATA, \"RCFile is empty: \" + fileSplit.getPath());\n        }\n\n        FSDataInputStream inputStream;\n        Path path = new Path(fileSplit.getPath());\n        try {\n            inputStream = hdfsEnvironment.getFileSystem(session.getUser(), path, configuration).openFile(path, hiveFileContext);\n        }\n        catch (Exception e) {\n            if (nullToEmpty(e.getMessage()).trim().equals(\"Filesystem closed\") ||\n                    e instanceof FileNotFoundException) {\n                throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, e);\n            }\n            throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, splitError(e, fileSplit), e);\n        }\n\n        try {\n            ImmutableMap.Builder<Integer, Type> readColumns = ImmutableMap.builder();\n            for (HiveColumnHandle column : columns) {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/rcfile/RcFilePageSourceFactory.java#L106-L142","documentation":"During createPageSource, if the HiveFileSplit reports fileSize == 0, Presto throws HIVE_BAD_DATA 'RCFile is empty: <path>'. An RCFile cannot be valid with zero length (no header, no metadata), so the connector refuses to open it instead of producing a mysterious decode failure later. This usually means the file was created but never written, or metadata is stale.","triggerScenarios":"createPageSource is invoked for a split whose fileSplit.getFileSize() returns 0 — a zero-byte file listed in a partition's file list.","commonSituations":"An upstream job failed after creating the output file but before writing data, HDFS 'touchz' placeholder files left in a partition directory, or stale partition metadata pointing at deleted/emptied files.","solutions":["Inspect the file ('hdfs dfs -ls -h <path>'); if it is a 0-byte artifact of a failed job, delete it and re-run the producing job to regenerate the data.","Repair the partition metadata: 'MSCK REPAIR TABLE' or drop/re-add the partition so it no longer references empty files.","Remove stray placeholder files created with 'hdfs dfs -touchz' from the table location.","Fix the upstream writer to write to a temp path and atomically rename on success so zero-byte files never become visible.","If the file genuinely should have data, check for HDFS under-replication/loss and restore from backup or source."],"exampleFix":"// before: zero-byte file visible to the partition\nhdfs dfs -touchz /data/events/ds=20260901/part-0000.rc\n// after: delete it and repair the partition\nhdfs dfs -rm /data/events/ds=20260901/part-0000.rc\nMSCK REPAIR TABLE events;","handlingStrategy":"validation","validationCode":"// Before listing/querying a partition, filter out zero-byte files:\nFileSystem fs = path.getFileSystem(conf);\nfor (FileStatus f : fs.listStatus(partitionDir)) {\n    if (f.getLen() == 0) {\n        log.warn(\"Skipping/flagging empty file: %s\", f.getPath());\n        // repair partition or delete placeholder before querying\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    pageSource = factory.createPageSource(...);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == HIVE_BAD_DATA.toErrorCode() && e.getMessage().startsWith(\"RCFile is empty:\")) {\n        log.warn(\"Skipping empty file reported by Presto\");\n        // trigger MSCK REPAIR TABLE / re-ingestion, then retry\n    } else {\n        throw e;\n    }\n}","preventionTips":["Write upstream output to temp dirs and atomically rename on job success.","Never leave 'touchz' placeholders in live table locations.","Run MSCK REPAIR TABLE (or drop/re-add partitions) after cleaning table directories.","Add ingestion pipeline checks that fail the job if any output file is 0 bytes.","Periodically audit partitions for empty files before scheduling queries."],"tags":["hive","rcfile","empty-file","hdfs","bad-data"],"backgroundTag":"empty-input-file","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"}