{"record":{"id":"2150621297acba04","repo":"prestodb/presto","slug":"rcbinary-encoder-does-not-support-empty-varbinary","errorCode":null,"errorMessage":"RCBinary encoder does not support empty VARBINARY values (HIVE-2483). Use ORC or Parquet format instead.","messagePattern":"RCBinary encoder does not support empty VARBINARY values \\(HIVE-2483\\)\\. Use ORC or Parquet format instead\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-rcfile/src/main/java/com/facebook/presto/rcfile/binary/BinaryEncoding.java","lineNumber":46,"sourceCode":"\npublic class BinaryEncoding\n        implements BinaryColumnEncoding\n{\n    private final Type type;\n\n    public BinaryEncoding(Type type)\n    {\n        this.type = type;\n    }\n\n    @Override\n    public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput)\n    {\n        for (int position = 0; position < block.getPositionCount(); position++) {\n            if (!block.isNull(position)) {\n                Slice slice = type.getSlice(block, position);\n                if (slice.length() == 0) {\n                    throw new IllegalArgumentException(\"RCBinary encoder does not support empty VARBINARY values (HIVE-2483). Use ORC or Parquet format instead.\");\n                }\n                output.writeBytes(slice);\n            }\n            encodeOutput.closeEntry();\n        }\n    }\n\n    @Override\n    public void encodeValueInto(Block block, int position, SliceOutput output)\n    {\n        Slice slice = type.getSlice(block, position);\n        // Note binary nested in complex structures do no use the empty marker.\n        // Therefore, empty VARBINARY values are ok.\n        writeVInt(output, slice.length());\n        output.writeBytes(slice);\n    }\n\n    @Override","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-rcfile/src/main/java/com/facebook/presto/rcfile/binary/BinaryEncoding.java#L28-L64","documentation":"The RCBinary VARBINARY encoder writes raw bytes with no length prefix trick for empty values; due to Hive bug HIVE-2483 an empty VARBINARY would corrupt the stream, so the encoder explicitly refuses. This is a writer-side hard failure, thrown as IllegalArgumentException.","triggerScenarios":"Calling BinaryEncoding.encodeColumn on a Block containing at least one non-null VARBINARY value of length 0 — e.g. INSERT INTO an RCFile table with an empty string/binary value ''.","commonSituations":"Inserting '' or empty binary literals into RCFile tables; ETL pipelines producing empty VARBINARY columns; migrating data containing empty blobs into RCBinary format.","solutions":["Replace empty VARBINARY values with NULL before writing (e.g. nullif(val, ''))","Use ORC or Parquet table format instead of RCFile, which handle empty values correctly","Upgrade Hive/Presto versions where HIVE-2483 may be worked around","Catch IllegalArgumentException from the writer and substitute a sentinel value"],"exampleFix":"// before\nINSERT INTO rc_table VALUES ('');\n// after\nINSERT INTO rc_table VALUES (CAST(NULL AS varchar)); -- or nullif(col, '')","handlingStrategy":"validation","validationCode":"// before writing a VARBINARY column to RCBinary\nfor (int pos = 0; pos < block.getPositionCount(); pos++) {\n    if (!block.isNull(pos) && type.getSlice(block, pos).length() == 0) {\n        throw new IllegalArgumentException(\"empty VARBINARY not writable to RCBinary (HIVE-2483)\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try { encoding.encodeColumn(block, output, encodeOutput); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"HIVE-2483\")) {\n        block = nullifyEmptyVarbinary(block); // rewrite '' as NULL and retry\n    } else { throw e; }\n}","preventionTips":["Coalesce empty binary values to NULL before writing to RCFile","Prefer ORC/Parquet when data may contain empty VARBINARY values","Know HIVE-2483 when migrating legacy Hive RCFile data","Add a pre-write lint for zero-length binary/string values"],"tags":["rcfile","rcbinary","varbinary","hive-bug"],"backgroundTag":"empty-value-not-supported","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"}