forked from lance-format/lance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fork.py
More file actions
44 lines (33 loc) · 1014 Bytes
/
test_fork.py
File metadata and controls
44 lines (33 loc) · 1014 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
40
41
42
43
44
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright The Lance Authors
import os
import sys
from pathlib import Path
import lance
import pyarrow as pa
import pyarrow.compute as pc
import pytest
N_DIMS = 768
NUM_ROWS = 100_000
NEW_ROWS = 10_000
def create_table(num_rows) -> pa.Table:
return pa.table(
{
"a": pc.random(num_rows).cast(pa.float32()),
"b": pa.array(range(0, num_rows)),
}
)
@pytest.mark.skipif(sys.platform == "win32", reason="Test not applicable on Windows")
def test_table_roundtrip(tmp_path: Path):
uri = tmp_path
tbl = create_table(100)
lance.write_dataset(tbl, uri)
os.fork()
dataset = lance.dataset(uri)
assert dataset.uri == str(uri.absolute())
assert tbl.schema == dataset.schema
assert tbl == dataset.to_table()
one_col = dataset.to_table(columns=["a"])
assert one_col == tbl.select(["a"])
table = dataset.to_table(columns=["a"], limit=20)
assert len(table) == 20