apache/iceberg · error · IllegalArgumentException
Unsupported compression codec
Error message
Unsupported compression codec: %s
What it means
Parquet.Context.toCodec converts a user-supplied compression codec string to a Parquet CompressionCodecName; unknown names raise this IllegalArgumentException. It validates the write compression setting before any file is written.
Solutions
- Use one of the valid codec names: NONE, UNCOMPRESSED, SNAPPY, GZIP, LZO, BROTLI, LZ4, ZSTD
- Check for whitespace or casing issues in the configured value
- Upgrade parquet-mr/Iceberg if the codec (e.g. ZSTD) isn't in the enum version you use
Example fix
// before
table.updateProperties().set("write.parquet.compression-codec", "gzip2").commit();
// after
table.updateProperties().set("write.parquet.compression-codec", "GZIP").commit(); Defensive patterns
Strategy: validation
Validate before calling
String codec = props.getProperty("write.parquet.compression-codec");
if (codec != null) {
Set<String> valid = Set.of("NONE","UNCOMPRESSED","SNAPPY","GZIP","LZO","BROTLI","LZ4","ZSTD");
Preconditions.checkArgument(valid.contains(codec.toUpperCase(Locale.ROOT)), "Unsupported compression codec: %s", codec);
} Try / catch
try {
newContext();
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported compression codec")) { /* correct the property */ }
else throw e;
} Prevention
- Keep an allowlist of valid codec names in config validation
- Trim and normalize codec config values before use
- Verify the codec is available in your parquet-mr version (e.g. ZSTD needs parquet >= 1.9/1.10)
When it happens
Trigger: Passing TableProperties.WRITE_COMPRESSION_CODEC / Parquet.PARQUET_COMPRESSION with a value not matching a Parquet codec enum name (valueOf is case-insensitive via toUpperCase but the name must otherwise match exactly).
Common situations: Typos like 'snappy ' or 'lz4hadoop' or 'brotli' on unsupported versions; setting the property with engine-specific codec names not present in parquet-mr's enum.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Class was not found
- Fallback ID assignment in Parquet is UNSAFE and will be…
- Skipping bloom filter config for missing field
- Skipping column statistics config for missing field
- Skipping dictionary encoding config for missing field
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/7886e9dfa3da4ee3.
Report an issue: GitHub.
Appendix: source
Thrown at parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java:794
compressionLevel,
rowGroupCheckMinRecordCount,
rowGroupCheckMaxRecordCount,
PARQUET_BLOOM_FILTER_MAX_BYTES_DEFAULT,
PARQUET_BLOOM_FILTER_ADAPTIVE_ENABLED_DEFAULT,
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableMap.of(),
dictionaryEnabled,
ImmutableMap.of(),
dataContext.trackUncompressedRowGroupSize());
}
private static CompressionCodecName toCodec(String codecAsString) {
try {
return CompressionCodecName.valueOf(codecAsString.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unsupported compression codec: " + codecAsString);
}
}
private static WriterVersion toWriterVersion(String pageVersion) {
try {
return WriterVersion.fromString(pageVersion);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Unsupported Parquet page version: " + pageVersion + " (must be v1 or v2)");
}
}
int rowGroupSize() {
return rowGroupSize;
}
int pageSize() {
return pageSize;View on GitHub (pinned to 86d9c8fc54)