Skip to content

Commit

Permalink
[Minor]: Refactor to use Result.transpose() (#11882)
Browse files Browse the repository at this point in the history
`Result.transpose()` converts `Result<Option<T>>` to `Option<Result<T>>`.

> Ok(None) will be mapped to None. Ok(Some(_)) and Err(_) will be mapped to Some(Ok(_)) and Some(Err(_)).
- https://doc.rust-lang.org/std/result/enum.Result.html#method.transpose
  • Loading branch information
djanderson authored Aug 8, 2024
1 parent 053795c commit 0bbce5d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions datafusion/core/src/datasource/physical_plan/arrow_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,9 @@ impl FileOpener for ArrowOpener {
.into_iter()
.zip(recordbatch_results)
.filter_map(move |(block, data)| {
match decoder.read_record_batch(&block, &data.into()) {
Ok(Some(record_batch)) => Some(Ok(record_batch)),
Ok(None) => None,
Err(err) => Some(Err(err)),
}
decoder
.read_record_batch(&block, &data.into())
.transpose()
}),
)
.boxed())
Expand Down

0 comments on commit 0bbce5d

Please sign in to comment.