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

Remove non idiomatic DataFusionError::into_arrow_external_error in favor of From conversion #1645

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jan 22, 2022

Builds on #1643, so draft until that is merged

Which issue does this PR close?

closes #1644

Rationale for this change

The way to convert DataFusionError into an ArrowError is confusing for Rust programmers coming to the DataFusion codebase and makes our codebase a bit of a mess

DataFusionError::into_arrow_external_error

They typically expect a impl From<..> conversion trait

What changes are included in this PR?

  1. remove DataFusionError::into_arrow_external_error
  2. Update code to use From impl instead

Are there any user-facing changes?

Nicer error handling, but removal of into_arrow_external_error

@alamb alamb added the api change Changes the API exposed to users of the crate label Jan 22, 2022
@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Jan 22, 2022
@@ -331,8 +331,7 @@ fn build_batch(
let scalar = ScalarValue::try_from_array(arr, left_index)?;
Ok(scalar.to_array_of_size(batch.num_rows()))
})
.collect::<Result<Vec<_>>>()
.map_err(|x| x.into_arrow_external_error())?;
.collect::<Result<Vec<_>>>()?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a pretty good exemplar of how this change makes the DataFusion codebase less confusing

@alamb
Copy link
Contributor Author

alamb commented Jan 22, 2022

We can probably remove any instances of code like

                    .map_err(DataFusionError::ArrowError)

as well 🤔

@alamb alamb marked this pull request as ready for review January 22, 2022 20:16
Copy link
Member

@houqp houqp left a comment

Choose a reason for hiding this comment

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

nice cleanup

@alamb alamb merged commit 741df36 into apache:master Jan 24, 2022
@alamb alamb deleted the alamb/error-cleanup2 branch January 24, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api change Changes the API exposed to users of the crate datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove DataFusionError::into_arrow_external_error in favor of From conversion
2 participants