Skip to content

Commit

Permalink
introduce odbc_to_arrow_error
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed May 18, 2024
1 parent bb95aa1 commit 7ea970b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/reader/concurrent_odbc_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use odbc_api::{buffers::ColumnarAnyBuffer, BlockCursor, ConcurrentBlockCursor, C

use crate::Error;

use super::to_record_batch::ToRecordBatch;
use super::{odbc_reader::odbc_to_arrow_error, to_record_batch::ToRecordBatch};

/// Arrow ODBC reader. Implements the [`arrow::record_batch::RecordBatchReader`] trait so it can be
/// used to fill Arrow arrays from an ODBC data source. Similar to [`crate::OdbcReader`], yet
Expand Down Expand Up @@ -134,7 +134,7 @@ where
Ok(false) => None,
// We had an error fetching the next batch from the database, let's report it as an
// external error.
Err(odbc_error) => Some(Err(ArrowError::ExternalError(Box::new(odbc_error)))),
Err(odbc_error) => Some(Err(odbc_to_arrow_error(odbc_error))),
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/reader/odbc_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ where
Ok(None) => None,
// We had an error fetching the next batch from the database, let's report it as an
// external error.
Err(odbc_error) => Some(Err(ArrowError::ExternalError(Box::new(odbc_error)))),
Err(odbc_error) => Some(Err(odbc_to_arrow_error(odbc_error))),
}
}
}
Expand Down Expand Up @@ -358,3 +358,7 @@ impl OdbcReaderBuilder {
})
}
}

pub fn odbc_to_arrow_error(odbc_error: odbc_api::Error) -> ArrowError {
ArrowError::from_external_error(Box::new(odbc_error))
}

0 comments on commit 7ea970b

Please sign in to comment.