Skip to content

Commit

Permalink
reuse state
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco committed May 7, 2024
1 parent e370d34 commit 8617c80
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python/deltalake/_internal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ class DeltaFileSystemHandler:

def __init__(
self,
root: str,
table: RawDeltaTable,
options: dict[str, str] | None = None,
known_sizes: dict[str, int] | None = None,
) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion python/deltalake/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ def to_pyarrow_dataset(
}
filesystem = pa_fs.PyFileSystem(
DeltaStorageHandler(
self._table.table_uri(), self._storage_options, file_sizes
self._table, self._storage_options, file_sizes
)
)
format = ParquetFileFormat(
Expand Down
14 changes: 5 additions & 9 deletions python/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::sync::Arc;

use crate::error::PythonError;
use crate::utils::{delete_dir, rt, walk_tree};
use crate::RawDeltaTable;
use deltalake::storage::{DynObjectStore, ListResult, MultipartId, ObjectStoreError, Path};
use deltalake::DeltaTableBuilder;
use pyo3::exceptions::{PyIOError, PyNotImplementedError, PyValueError};
use pyo3::prelude::*;
use pyo3::types::{IntoPyDict, PyBytes};
Expand Down Expand Up @@ -41,21 +41,17 @@ impl DeltaFileSystemHandler {
#[pymethods]
impl DeltaFileSystemHandler {
#[new]
#[pyo3(signature = (table_uri, options = None, known_sizes = None))]
#[pyo3(signature = (table, options = None, known_sizes = None))]
fn new(
table_uri: &str,
table: &RawDeltaTable,
options: Option<HashMap<String, String>>,
known_sizes: Option<HashMap<String, i64>>,
) -> PyResult<Self> {
let storage = DeltaTableBuilder::from_uri(table_uri)
.with_storage_options(options.clone().unwrap_or_default())
.build_storage()
.map_err(PythonError::from)?
.object_store();
let storage = table._table.object_store();
Ok(Self {
inner: storage,
config: FsConfig {
root_url: table_uri.into(),
root_url: table._table.table_uri(),
options: options.unwrap_or_default(),
},
known_sizes,
Expand Down

0 comments on commit 8617c80

Please sign in to comment.