Skip to content

Commit

Permalink
add tests and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PengLiVectra committed Nov 29, 2023
1 parent dcf0b3a commit ad082dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 0 additions & 1 deletion python/deltalake/_internal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class RawDeltaTable:
@staticmethod
def load_lazy(
table_uri: str,
version: Optional[int],
storage_options: Optional[Dict[str, str]],
without_files: bool,
log_buffer_size: Optional[int],
Expand Down
1 change: 0 additions & 1 deletion python/deltalake/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ def __init__(
if lazy_load:
self._table = RawDeltaTable.load_lazy(
str(table_uri),
version=version,
storage_options=storage_options,
without_files=without_files,
log_buffer_size=log_buffer_size,
Expand Down
6 changes: 1 addition & 5 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,10 @@ impl RawDeltaTable {
}

#[classmethod]
#[pyo3(signature = (table_uri, version = None, storage_options = None, without_files = false, log_buffer_size = None))]
#[pyo3(signature = (table_uri, storage_options = None, without_files = false, log_buffer_size = None))]
fn load_lazy(
_cls: &PyType,
table_uri: &str,
version: Option<i64>,
storage_options: Option<HashMap<String, String>>,
without_files: bool,
log_buffer_size: Option<usize>,
Expand All @@ -138,9 +137,6 @@ impl RawDeltaTable {
if let Some(storage_options) = storage_options {
builder = builder.with_storage_options(storage_options)
}
if let Some(version) = version {
builder = builder.with_version(version)
}
if without_files {
builder = builder.without_files()
}
Expand Down
19 changes: 19 additions & 0 deletions python/tests/test_table_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ def test_read_simple_table_using_options_to_dict():
assert dt.to_pyarrow_dataset().to_table().to_pydict() == {"value": [1, 2, 3]}


def test_simple_table_lazy_loading():
table_path = "../crates/deltalake-core/tests/data/simple_table"
dt = DeltaTable(table_path, lazy_load=True)
dt.load_version(2)
assert dt.version() == 2


def test_simple_table_lazy_loading_with_options():
table_path = "../crates/deltalake-core/tests/data/simple_table"
dt = DeltaTable(
table_path,
storage_options={},
without_files=False,
log_buffer_size=1,
lazy_load=True,
)
assert isinstance(dt, DeltaTable)


def test_load_with_datetime():
log_dir = "../crates/deltalake-core/tests/data/simple_table/_delta_log"
log_mtime_pair = [
Expand Down

0 comments on commit ad082dd

Please sign in to comment.