This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new 2549061f9 Avro: read a file without avro.codec as uncompressed (#4296)
2549061f9 is described below
commit 2549061f904af87f85e1201f1bd6dc3ab2f1ba2c
Author: Javier de la Torre <[email protected]>
AuthorDate: Mon Nov 9 17:30:23 2026 +0000
Avro: read a file without avro.codec as uncompressed (#4296)
The Avro specification makes null the default codec. PyIceberg fell back to
the Iceberg table
property default (gzip), which is not an Avro codec name, so it raised
'Unsupported codec: gzip' on
manifests written without the entry (iceberg-rust writes them so).
---
pyiceberg/avro/file.py | 7 +++----
tests/avro/test_file.py | 6 ++++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/pyiceberg/avro/file.py b/pyiceberg/avro/file.py
index 3184e3950..4b23c30ac 100644
--- a/pyiceberg/avro/file.py
+++ b/pyiceberg/avro/file.py
@@ -88,11 +88,10 @@ class AvroFileHeader(Record):
"""Get the file's compression codec algorithm from the file's metadata.
In the case of a null codec, we return a None indicating that we
- don't need to compress/decompress.
+ don't need to compress/decompress. A file without the avro.codec
+ entry is uncompressed: the Avro specification makes "null" the default.
"""
- from pyiceberg.table import TableProperties
-
- codec_name = self.meta.get(AVRO_CODEC_KEY,
TableProperties.WRITE_AVRO_COMPRESSION_DEFAULT)
+ codec_name = self.meta.get(AVRO_CODEC_KEY, "null")
if codec_name not in KNOWN_CODECS:
raise ValueError(f"Unsupported codec: {codec_name}")
diff --git a/tests/avro/test_file.py b/tests/avro/test_file.py
index 6cc190c33..12d1af2ce 100644
--- a/tests/avro/test_file.py
+++ b/tests/avro/test_file.py
@@ -71,6 +71,12 @@ def get_null_compressor() -> None:
assert header.compression_codec() is None
+def test_missing_codec_is_null() -> None:
+ # the Avro specification: a file without avro.codec is uncompressed
(iceberg-rust writes such manifests)
+ header = AvroFileHeader(bytes(0), {}, bytes(16))
+ assert header.compression_codec() is None
+
+
def test_unknown_codec() -> None:
header = AvroFileHeader(bytes(0), {"avro.codec": "unknown"}, bytes(16))