Skip to content

Fix Result name collision in parquet_derive #7548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jspaezp
Copy link

@jspaezp jspaezp commented May 24, 2025

Which issue does this PR close?

Closes #7547

Rationale for this change

Explained in the issue.

What changes are included in this PR?

Pretty simple change from Result to std::result::Result to prevent the 'name collision' on the code/text generated from the macro.

Are there any user-facing changes?

None that I can think of.

Please let me know if there is anything else you might want/need on my end! and thank you very much for this project.

@alamb
Copy link
Contributor

alamb commented May 26, 2025

Thank you for the contribution @jspaezp

This code looks good to me. Is there any chance you can make a test for this (that would fail if we accidentally broke this feature)? Perhaps you could make a small parquet-derive/test/macro_hygene.rs style test , similarly to https://github.com/apache/datafusion/blob/main/datafusion/core/tests/macro_hygiene/mod.rs

@jspaezp
Copy link
Author

jspaezp commented May 27, 2025

@alamb thanks for the fast reply! I added a test (added it in parquet_derive_test/src/lib.rs rather than parquet-derive/test/macro_hygene.rs).

LMK if this is what you had in mind!

Copy link
Contributor

@crepererum crepererum left a comment

Choose a reason for hiding this comment

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

I think we can make the test even harder. Other than that, solid fix!


mod aliased_result {
use parquet_derive::{ParquetRecordReader, ParquetRecordWriter};
pub type Result = std::result::Result<(), Box<dyn std::error::Error>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub type Result = std::result::Result<(), Box<dyn std::error::Error>>;
// not an actual result type
pub type Result = ();

Copy link
Author

Choose a reason for hiding this comment

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

Did the modification but left the other one commented out so there is a bit more historical context (hope thats ok)

}

impl ARecord {
pub fn validate(&self) -> Result {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub fn validate(&self) -> Result {
pub fn validate(&self) -> std::result::Result<(), Box<dyn std::error::Error>> {

(so it doesn't use our Result shadow)

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 @jspaezp and @crepererum ❤️

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

Successfully merging this pull request may close these issues.

Parquet derive fails to build when Result is aliased
3 participants