Revert "Seal Array trait (#9092)", mark Array as unsafe#9234
Revert "Seal Array trait (#9092)", mark Array as unsafe#9234alamb merged 2 commits intoapache:mainfrom
Array as unsafe#9234Conversation
This reverts commit 721f373.
alamb
left a comment
There was a problem hiding this comment.
Thanks @gabotechs -- this looks good to me
I have some comment suggestions, but I also think we could do them as a follow on PR
Array as unsafe
441b818 to
592bd0a
Compare
592bd0a to
946931b
Compare
|
I plan to merge this tomorrow, unless there are any additional comments |
|
Thanks again @gabotechs |
scovich
left a comment
There was a problem hiding this comment.
If we're adding scary docs to explain why it's unadvisable to manually impl this trait, it seems like we're missing one of the biggest reasons?
It's impossible to correctly implement the trait for third party types, because casting is based on the return values of Array::data_type, and third party types cannot extend enum DataType. So any code that attempts casting based on data type (including internal arrow library code) risks a panic.
|
@scovich completely agree, and I think it makes sense that eventually this trait gets sealed. However, some crates are do willing to risk panics in order to benefit from the flexibility of |
Understood. I was just commenting that the documentation in this PR, explaining why it's marked Or maybe there's enough truly unsafe code at risk to outweigh the "mere" panic risk of a cast gone bad? |
The closest thing it mentions is that "panics" can happen, it does not enumerate which places specifically. If you have any suggestions about more things to add to the safety comment they are more than welcome. |
|
Skimming down the list of methods:
Summing it all up -- any custom Array implementation must either be a complex analogue to
Problem is -- there's no way to tell which one you're dealing with, for an arbitrary If we really wanted to support the use case of |
…ache#9234) This reverts commit 721f373. # Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. --> - Discussed in apache#9184 - Closes apache#9184 # Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> As discussed in Discussed in apache#9184, rather than sealing the `Array` trait, it's going to potentially be marked `unsafe` so that projects have time to find alternatives for their use-cases that are now satisfied by a custom `Array` implementation. # What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Clean revert of apache#9092 # Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Not applicable here # Are there any user-facing changes? Yes, users can no implement the `Array` trait in their codebases again. <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. If there are any breaking changes to public APIs, please call them out. -->
|
I also created a PR to try and summarize the discussion about DataType in the comments: |
…unsafe` (#9234) (#9313) - Part of #9240 - Related to #9184 This is a backport of the following PR to the 57 line - #9234 from @gabotechs As discussed in #9184, rather than sealing the Array trait which broke several downstream crates, this PR markes the trait as `unsafe` so that projects have time to find alternatives for their use-cases that are now satisfied by a custom Array implementation. Co-authored-by: Gabriel <[email protected]>
# Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. --> - Closes #NNN. # Rationale for this change Per discussion on #9234 (review) @scovich noted that it would be good to point out the core reason it is hard/impossible to implement Array safetly # What changes are included in this PR? Update the comments on `Array` to try and capture the thread. # Are these changes tested? By CI # Are there any user-facing changes? Docs only, no functional changes
This reverts commit 721f373.
Which issue does this PR close?
Arraytrait broke downstream crates #9184Arraytrait broke downstream crates #9184Rationale for this change
As discussed in Discussed in #9184, rather than sealing the
Arraytrait, it's going to potentially be markedunsafeso that projects have time to find alternatives for their use-cases that are now satisfied by a customArrayimplementation.What changes are included in this PR?
Clean revert of #9092
Are these changes tested?
Not applicable here
Are there any user-facing changes?
Yes, users can no implement the
Arraytrait in their codebases again.