Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fecet committed Dec 18, 2024
1 parent 4dcb8c4 commit eb0a770
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions python/python/tests/test_balanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ def balanced_dataset(tmp_path, big_val):
)


def test_write_fragments(balanced_dataset, tmp_path):
tbl = balanced_dataset._take_rows(range(10))
default_frags, blob_frags = lance.fragment.write_fragments(
tbl,
tmp_path / "ds",
with_blobs=True,
enable_move_stable_row_ids=True,
)
operation = lance.LanceOperation.Overwrite(tbl.schema, default_frags)
blob_operation = lance.LanceOperation.Overwrite(
pa.schema([tbl.schema.field("blobs")]), blob_frags
)

ds = lance.LanceDataset.commit(
tmp_path / "ds",
operation,
blobs_operation=blob_operation,
enable_v2_manifest_paths=True,
)
dataset = lance.LanceDataset(tmp_path / "ds")

assert dataset._take_rows(range(10)) == balanced_dataset._take_rows(range(10))


def test_append_then_take(balanced_dataset, tmp_path, big_val):
blob_dir = tmp_path / "test_ds" / "_blobs" / "data"
assert len(list(blob_dir.iterdir())) == 8
Expand Down
4 changes: 2 additions & 2 deletions python/python/tests/test_fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def test_create_from_file(tmp_path):
frag = LanceFragment.create_from_file(fragment_name, dataset, 0)
op = LanceOperation.Append([frag])

dataset = lance.LanceDataset.commit(dataset.uri, op, dataset.version)
dataset = lance.LanceDataset.commit(dataset.uri, op, read_version=dataset.version)
frag = dataset.get_fragments()[0]
assert frag.fragment_id == 0

Expand All @@ -331,7 +331,7 @@ def test_create_from_file(tmp_path):
frag = LanceFragment.create_from_file(fragment_name, dataset, 0)
op = LanceOperation.Append([frag])

dataset = lance.LanceDataset.commit(dataset.uri, op, dataset.version)
dataset = lance.LanceDataset.commit(dataset.uri, op, read_version=dataset.version)
frag = dataset.get_fragments()[1]
assert frag.fragment_id == 1

Expand Down

0 comments on commit eb0a770

Please sign in to comment.