Skip to content
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

Implement Error::Source for ArrowError and FlightError #3566

Closed
alamb opened this issue Jan 19, 2023 · 5 comments · Fixed by #3567
Closed

Implement Error::Source for ArrowError and FlightError #3566

alamb opened this issue Jan 19, 2023 · 5 comments · Fixed by #3567
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@alamb
Copy link
Contributor

alamb commented Jan 19, 2023

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In IOx (and in DataFusion) we often want to know what the root cause of an error is (e.g was it a bug or was it a resources exhausted). ArrowError can wrap other errors with Arrow::External (and DataFusion has something similar) but there is no easy way to get at the source of the error to walk the chain without knowing all the possible types that may be present

I believe this is what https://doc.rust-lang.org/std/error/trait.Error.html#method.source is for

I would like to be able to write something like this to walk the chain

        let mut root_error: &dyn Error = &e3;
        loop {
            match root_error.source() {
                // walk the next level
                Some(source) => root_error = source,
                // at root (as much as we know)
                None => break,
            }
        }

However, ArrowError does not implement source yet

Of course, all the errors in the chain need to implement this

Describe the solution you'd like
For ArrowError / FlightError that wrap other errors, implement Error::source()

Describe alternatives you've considered
See https://github.com/apache/arrow-datafusion/blob/dde23efed94704044822bcefe49c0af7f9260088/datafusion/common/src/error.rs#L361-L439 for what we need to do now in datafusion 🤮

cc @crepererum

Additional context

@alamb alamb added the enhancement Any new improvement worthy of a entry in the changelog label Jan 19, 2023
@crepererum
Copy link
Contributor

I think we should replace the find_root method in DataFusion with this mechanism as well and embrace the standard 💪

@alamb
Copy link
Contributor Author

alamb commented Jan 19, 2023

I think we should replace the find_root method in DataFusion with this mechanism as well and embrace the standard 💪

On it!

@alamb
Copy link
Contributor Author

alamb commented Jan 19, 2023

Follow on ticket in datafusion: apache/datafusion#4991

@tustvold tustvold added the arrow Changes to the arrow crate label Jan 27, 2023
@tustvold
Copy link
Contributor

label_issue.py automatically added labels {'arrow'} from #3567

@tustvold tustvold added the arrow-flight Changes to the arrow-flight crate label Jan 27, 2023
@tustvold
Copy link
Contributor

label_issue.py automatically added labels {'arrow-flight'} from #3567

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-flight Changes to the arrow-flight crate enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants