-
Notifications
You must be signed in to change notification settings - Fork 881
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
downcast_primitive_array
and downcast_dictionary_array
are not hygienic wrt imports
#6400
Comments
This isn't a bug, it's inherent to the nature of macros and the limitations thereof. I'm not aware of any way to avoid this. If you wish to use a macro, you have to have the defining crate in scope |
I broadly agree, though in this case the defining crate is
|
Yeah, this is an artifact of when the crates were split apart. I suppose we could add a private re-export of arrow-schema within arrow-array for this specific case, but you'd still not be able to use the macro from a top-level crate like datafusion or arrow. |
If the re-export was public but hidden, then it would roughly fix the issue. Another option could be to make the top-level Neither solution is particularly satisfying :( |
TLDR I think we should make this work even if it is non ideal (like a copy of the macro) as it is a usability papercut In general, I think most/many users use the I don't think we should prevent / make it harder for people to use the subcrates (doing so reduces the dependency burden on downstream projects) but I think using subcrates has a higher barrier to entry. I think it is important to make it as easy as possible for people to start using arrow and then if they find it useful they can spend time to optimize their usage more |
I wonder if we could create a meta-macro that generates the downcast_primitive_array macro, this would avoid duplication, and allow redefining the downcast macro when re-exporting 🤔 |
* Make downcast macros hygenic (#6400) * Format * Update arrow-array/src/cast.rs Co-authored-by: Andrew Lamb <[email protected]> * fix fmt --------- Co-authored-by: Andrew Lamb <[email protected]>
|
Describe the bug
Using
downcast_primitive_array
anddowncast_dictionary_array
requirearrow_schema
to be in scope of the expanded code.To Reproduce
arrow::downcast_primitive_array
withoutarrow_schema
included as a direct dependencyarrow_schema
Expected behavior
Compile should succeed.
Additional context
A workaround is to manually insert something which roughly matches
arrow_schema
into the namespace, e.g.The text was updated successfully, but these errors were encountered: