fix(avro): advance the decoder when skipping an enum - #4009
Open
Rodrigo-Palma wants to merge 1 commit into
Open
Rodrigo-Palma wants to merge 1 commit into
Rodrigo-Palma wants to merge 1 commit into
Conversation
EnumReader.skip() was a no-op, so the enum's bytes stayed in the stream and the next field was decoded from them. Reading a manifest with the status field projected out returns wrong values for every field after it. Delegate to the wrapped reader, which is what read() already does.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4006
Rationale for this change
EnumReader.skip()waspass, so skipping an enum field left its bytes in the stream and every field after it in the record was decoded from the wrong offset.read()already delegates to the wrapped reader;skip()now does the same.This is reachable from ordinary reads: the manifest entry schema starts with the
statusenum (field id 0), so any read that projectsstatusout decodes the rest of the entry from the enum's bytes.Are these changes tested?
Yes, two tests in
tests/avro/test_resolver.py, each parametrized overStreamingBinaryDecoderandCythonBinaryDecoder(4 cases, all failing before this change):test_enum_reader_skip_advances_the_decoder: after skipping, the next field reads its own value.test_enum_reader_skip_matches_read: reading and skipping leave the decoder at the same position.pytest tests/ -m unit --ignore=tests/integrationgives 4215 passed. The 9 failures intests/avro/test_decoder.pyare present identically on an unmodifiedmainin this checkout (a stale compiled Cython extension) and are unrelated to this change.Are there any user-facing changes?
Yes: reads that skip an enum field now return correct values instead of misaligned ones. No API change.