Skip to content

Conversation

@jecsand838
Copy link
Contributor

@jecsand838 jecsand838 commented Sep 18, 2025

Which issue does this PR close?

This work continues arrow-avro schema resolution support and aligns behavior with the Avro spec.

Rationale for this change

@scovich left a really solid review on #8348 that wasn't completed until after the PR was merged in. This PR is for addressing the suggestions and improving the code.

What changes are included in this PR?

  • Code quality improvements to codec.rs
  • Improvements to schema.rs including spec compliant named type errors.

Are these changes tested?

  1. No functionality was added / modified in codec.rs and all existing tests are passing without changes.
  2. Two new unit tests were added to schema.rs to cover the spec compliant named type changes.

Are there any user-facing changes?

N/A

…a constraints, and improve error reporting. Add tests for missing union branch names, named type signatures, and codec validation. Optimize union variant resolution logic and simplify schema traversal for complex types.
@github-actions github-actions bot added arrow Changes to the arrow crate arrow-avro arrow-avro crate labels Sep 18, 2025
@jecsand838
Copy link
Contributor Author

jecsand838 commented Sep 18, 2025

@scovich Here's the follow-up that incorporates your recommendations. Let me know what you think.

Copy link
Contributor

@scovich scovich left a comment

Choose a reason for hiding this comment

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

LGTM, couple nits

}
}
}
let (reader_index, promotion) = direct.or(promo).ok_or_else(|| {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can delete direct now (L1363 above)?

Comment on lines 1842 to 1843
fn mk_primitive<'a>(pt: PrimitiveType) -> Schema<'a> {
Schema::TypeName(TypeName::Primitive(pt))
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting... 'a doesn't "attach" to any input arg? Not quite sure how that works in rust...

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work, out of curiosity?

Suggested change
fn mk_primitive<'a>(pt: PrimitiveType) -> Schema<'a> {
Schema::TypeName(TypeName::Primitive(pt))
fn mk_primitive(pt: PrimitiveType) -> Schema<'_> {
Schema::TypeName(TypeName::Primitive(pt))

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope... might be a case where 'static actually makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hit these same issues. Dealing with mk_primitive is initially what led me to make the others static.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll just change mk_primitive back to being static.

@jecsand838
Copy link
Contributor Author

LGTM, couple nits

@scovich Ty for the quick review. I just pushed up some improvements based on your comments. Let me know what you think.

@jecsand838 jecsand838 requested a review from scovich September 18, 2025 22:13
Copy link
Contributor

@scovich scovich left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @jecsand838 and @scovich

@alamb alamb merged commit 18be750 into apache:main Sep 19, 2025
23 checks passed
@jecsand838 jecsand838 deleted the avro-reader-union-support-codec-improvements branch September 22, 2025 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-avro arrow-avro crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants