forked from lance-format/lance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_session.py
More file actions
39 lines (23 loc) · 919 Bytes
/
test_session.py
File metadata and controls
39 lines (23 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright The Lance Authors
from pathlib import Path
import lance
import pyarrow as pa
def test_cache_size_bytes(
tmp_path: Path,
):
data = pa.table({"a": range(1000)})
lance.write_dataset(data, tmp_path, max_rows_per_file=250)
ds = lance.dataset(tmp_path)
initial_size = ds.session().size_bytes()
ds.scanner().to_table()
after_scan_size = ds.session().size_bytes()
assert after_scan_size > initial_size
def test_share_session(tmp_path: Path):
data = pa.table({"a": range(1000)})
ds1 = lance.write_dataset(data, tmp_path, max_rows_per_file=250)
assert ds1.to_table() == data
ds2 = lance.dataset(tmp_path, session=ds1.session())
assert ds1.session().is_same_as(ds2.session())
assert ds1.session().size_bytes() == ds2.session().size_bytes()
assert ds1.to_table() == ds2.to_table()