Skip to content

Commit

Permalink
expose a interface to get reader builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ZENOTME committed Jun 15, 2024
1 parent 396c7d0 commit 7f3e074
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/iceberg/src/arrow/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct ArrowReaderBuilder {

impl ArrowReaderBuilder {
/// Create a new ArrowReaderBuilder
pub fn new(file_io: FileIO, table_metadata: TableMetadataRef) -> Self {
pub(crate) fn new(file_io: FileIO, table_metadata: TableMetadataRef) -> Self {
ArrowReaderBuilder {
batch_size: None,
file_io,
Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ mod tests {
let string_arr = col.as_any().downcast_ref::<StringArray>().unwrap();
assert_eq!(string_arr.value(0), "Apache");
}

#[test]
fn test_file_scan_task_serialize_deserialize() {
let test_fn = |task: FileScanTask| {
Expand Down
11 changes: 11 additions & 0 deletions crates/iceberg/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

//! Table API for Apache Iceberg
use crate::arrow::ArrowReaderBuilder;
use crate::io::FileIO;
use crate::scan::TableScanBuilder;
use crate::spec::{TableMetadata, TableMetadataRef};
Expand Down Expand Up @@ -70,6 +71,11 @@ impl Table {
pub fn readonly(&self) -> bool {
self.readonly
}

/// Create a reader for the table.
pub fn reader_builder(&self) -> ArrowReaderBuilder {
ArrowReaderBuilder::new(self.file_io.clone(), self.metadata_ref())
}
}

/// `StaticTable` is a read-only table struct that can be created from a metadata file or from `TableMetaData` without a catalog.
Expand Down Expand Up @@ -138,6 +144,11 @@ impl StaticTable {
pub fn into_table(self) -> Table {
self.0
}

/// Create a reader for the table.
pub fn reader_builder(&self) -> ArrowReaderBuilder {
ArrowReaderBuilder::new(self.0.file_io.clone(), self.metadata())
}
}

#[cfg(test)]
Expand Down

0 comments on commit 7f3e074

Please sign in to comment.