Skip to content

test: Cover Avro compression codecs against fastavro - #4311

Merged
Fokko merged 1 commit into
apache:mainfrom
chenjian2664:chenjian2664/bytequay/test-avro-compression-codecs-with-fastavro
Nov 10, 2026
Merged

Fokko merged 1 commit into
apache:mainfrom
chenjian2664:chenjian2664/bytequay/test-avro-compression-codecs-with-fastavro

Conversation

@chenjian2664

Copy link
Copy Markdown
Contributor

Rationale for this change

No unit test reads or writes a snappy or bzip2 Avro block. The snappy checksum bug fixed in #2252 made every snappy-compressed Avro file unreadable, and nothing caught it. Exchanging files with fastavro in both directions checks each codec's block framing against an independent implementation of the Avro spec. A test that only compresses and decompresses with PyIceberg would miss a framing error that both sides share.

Are these changes tested?

Are there any user-facing changes?

No unit test read or wrote a snappy or bzip2 Avro block, so a broken
snappy checksum (fixed in apache#2252) went unnoticed. Exchanging files with
fastavro checks each codec's framing against an independent
implementation of the Avro spec.
@chenjian2664
chenjian2664 marked this pull request as ready for review November 9, 2026 04:45
Copilot AI balanced review requested due to automatic review settings November 9, 2026 04:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the added Avro codec interoperability tests.

No open issues 🎉

What changed in this PR

Adds Avro codec interoperability tests against fastavro to help catch block-framing regressions like the snappy checksum bug fixed in #2252.

Changes:

  • Covers null, deflate, bzip2, and snappy codecs.
  • Verifies that PyIceberg reads fastavro-written files and fastavro reads PyIceberg-written files.
  • Checks record contents in both directions and codec metadata on PyIceberg output.
File Description
tests/​avro/​test_file.py Adds parameterized, bidirectional codec interoperability coverage using fastavro.

Review effort: Balanced

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chenjian2664! 🙌 Nice — a bidirectional check against fastavro would have caught the snappy framing bug from #2252. Ran the suite locally, all green.

One small thing: could we also cover zstandard? It's a first-class codec for us (in KNOWN_CODECS, and a core dep) and fastavro writes it too — verified locally that it passes. See the suggestion below :)

Comment thread tests/avro/test_file.py
assert list(avro_reader) == records


@pytest.mark.parametrize("codec", ["null", "deflate", "bzip2", "snappy"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zstandard is also a first-class codec (a core dependency, no extra gating needed) and fastavro supports it — verified locally that this passes:

Suggested change
@pytest.mark.parametrize("codec", ["null", "deflate", "bzip2", "snappy"])
@pytest.mark.parametrize("codec", ["null", "deflate", "bzip2", "snappy", "zstandard"])

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion, apart from that, LGTM

@Fokko
Fokko added this pull request to the merge queue Nov 10, 2026
Merged via the queue into apache:main with commit 1561cd1 Nov 10, 2026
20 checks passed
@chenjian2664

Copy link
Copy Markdown
Contributor Author

@Fokko Thank you for the review and help!
I didn't notice the response sorry for that, but let me know if that comments still hold, I can file an small pr for it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants