From 0bbce5dce29df1123b0ab87a8907482c72d284c1 Mon Sep 17 00:00:00 2001 From: Douglas Anderson Date: Wed, 7 Aug 2024 20:32:57 -0600 Subject: [PATCH] [Minor]: Refactor to use Result.transpose() (#11882) `Result.transpose()` converts `Result>` to `Option>`. > 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 --- .../core/src/datasource/physical_plan/arrow_file.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/datafusion/core/src/datasource/physical_plan/arrow_file.rs b/datafusion/core/src/datasource/physical_plan/arrow_file.rs index e720b4efff6f..a1ee6fbe1341 100644 --- a/datafusion/core/src/datasource/physical_plan/arrow_file.rs +++ b/datafusion/core/src/datasource/physical_plan/arrow_file.rs @@ -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())