apache/beam · error · UnsupportedOperationException
Writing ZIP files is currently unsupported
Error message
Writing ZIP files is currently unsupported
What it means
Beam can read ZIP-compressed inputs (via FullZipInputStream) but has no ZIP writer; the ZIP variant of writeCompressed() unconditionally throws UnsupportedOperationException. Writing ZIP output is simply not implemented.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/io/Compression.java:133
@Override
public WritableByteChannel writeCompressed(WritableByteChannel channel) throws IOException {
return Channels.newChannel(
new BZip2CompressorOutputStream(Channels.newOutputStream(channel)));
}
},
/** Zip compression. */
ZIP(".zip", ".zip") {
@Override
public ReadableByteChannel readDecompressed(ReadableByteChannel channel) throws IOException {
FullZipInputStream zip = new FullZipInputStream(Channels.newInputStream(channel));
return Channels.newChannel(zip);
}
@Override
public WritableByteChannel writeCompressed(WritableByteChannel channel) throws IOException {
throw new UnsupportedOperationException("Writing ZIP files is currently unsupported");
}
},
/**
* ZStandard compression.
*
* <p>The {@code .zst} extension is specified in <a href=https://tools.ietf.org/html/rfc8478>RFC
* 8478</a>.
*
* <p>The Beam Java SDK does not pull in the Zstd library by default, so it is the user's
* responsibility to declare an explicit dependency on {@code zstd-jni}. Attempts to read or write
* .zst files without {@code zstd-jni} loaded will result in {@code NoClassDefFoundError} at
* runtime.
*/
ZSTD(".zst", ".zst", ".zstd") {
@Override
public ReadableByteChannel readDecompressed(ReadableByteChannel channel) throws IOException {
return Channels.newChannel(new ZstdCompressorInputStream(Channels.newInputStream(channel)));View on GitHub (pinned to 12126d8942)
Solutions
- Write with a supported compression (GZIP, BZIP2, or ZSTD) instead of ZIP.
- Write UNCOMPRESSED output and compress externally in a downstream job step if ZIP is mandatory.
- Add a custom sink wrapper that compresses output bytes into a zip archive yourself.
Example fix
// before .withCompression(Compression.ZIP) // after .withCompression(Compression.GZIP)
Defensive patterns
Strategy: validation
Validate before calling
if (compression == Compression.ZIP) {
throw new IllegalArgumentException("ZIP output unsupported; use GZIP/BZIP2/ZSTD");
} Try / catch
try {
out = compression.writeCompressed(channel);
} catch (UnsupportedOperationException e) {
out = Compression.GZIP.writeCompressed(channel);
} Prevention
- Use GZIP/BZIP2/ZSTD for compressed outputs
- Compress ZIP archives in a downstream step if ZIP is mandatory
- Check the Compression enum docs for read-only entries
When it happens
Trigger: Configuring an output sink with ZIP compression, e.g., FileIO.write().withCompression(Compression.ZIP) or TextIO sinks whose compression resolves to ZIP.
Common situations: Users assuming read/write symmetry across compression types; config templates that set zip for all IO; migrating gzip outputs to zip without checking support.
Related errors
- Must resolve compression into a concrete value before callin
- AUTO is applicable only to reading files
- Unsupported compression type: " + compression
- Failed to determine if the source is splittable
- AUTO is not supported for writing
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/5cd686a97461051c.
Report an issue: GitHub.