Skip to content

Commit

Permalink
chore: implement error handling for object_store
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiaagarwal committed Jun 14, 2024
1 parent e8285be commit b585f30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 3 additions & 7 deletions parquet/src/arrow/async_reader/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use futures::{FutureExt, TryFutureExt};
use object_store::{ObjectMeta, ObjectStore};

use crate::arrow::async_reader::{AsyncFileReader, MetadataLoader};
use crate::errors::{ParquetError, Result};
use crate::errors::Result;
use crate::file::metadata::ParquetMetaData;

/// Reads Parquet files in object storage using [`ObjectStore`].
Expand Down Expand Up @@ -105,7 +105,7 @@ impl AsyncFileReader for ParquetObjectReader {
fn get_bytes(&mut self, range: Range<usize>) -> BoxFuture<'_, Result<Bytes>> {
self.store
.get_range(&self.meta.location, range)
.map_err(|e| ParquetError::General(format!("AsyncChunkReader::get_bytes error: {e}")))
.map_err(|e| e.into())
.boxed()
}

Expand All @@ -117,11 +117,7 @@ impl AsyncFileReader for ParquetObjectReader {
self.store
.get_ranges(&self.meta.location, &ranges)
.await
.map_err(|e| {
ParquetError::General(format!(
"ParquetObjectReader::get_byte_ranges error: {e}"
))
})
.map_err(|e| e.into())
}
.boxed()
}
Expand Down
7 changes: 7 additions & 0 deletions parquet/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ impl From<ArrowError> for ParquetError {
}
}

#[cfg(feature = "object_store")]
impl From<object_store::Error> for ParquetError {
fn from(e: object_store::Error) -> ParquetError {
ParquetError::External(Box::new(e))
}
}

/// A specialized `Result` for Parquet errors.
pub type Result<T, E = ParquetError> = result::Result<T, E>;

Expand Down

0 comments on commit b585f30

Please sign in to comment.