-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: change the default data storage version to "stable" (e.g. v2.0) #2829
Merged
westonpace
merged 9 commits into
lancedb:main
from
westonpace:feat/change-default-to-v2
Sep 11, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
429f176
Change the default data storage version to "stable" (e.g. v2.0)
westonpace b401944
Fix bug in nested projection, rebase, properly report progress when c…
westonpace 30776ed
Cleanup and centralize v2 projection logic
westonpace 21c3a47
Add forward compatibility tests
westonpace 3e300a8
Copyright header
westonpace 2f6f31e
Fix datagen for forward compat tests
westonpace ff580ce
Pass in the --run-forward flag in CI
westonpace 321e56d
Remove print
westonpace 088e082
Don't change default for Java
westonpace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright The Lance Authors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright The Lance Authors | ||
|
||
# This script generates Lance files that are read by test_forward_compat.py | ||
|
||
from pathlib import Path | ||
|
||
import pyarrow as pa | ||
from lance.file import LanceFileWriter | ||
|
||
|
||
def get_path(name: str): | ||
dataset_dir = ( | ||
Path(__file__).parent.parent.parent.parent.parent | ||
/ "test_data" | ||
/ "forward_compat" | ||
/ name | ||
) | ||
return dataset_dir | ||
|
||
|
||
def build_basic_types(): | ||
schema = pa.schema( | ||
[ | ||
pa.field("int", pa.int64()), | ||
pa.field("float", pa.float32()), | ||
pa.field("str", pa.string()), | ||
pa.field("list_int", pa.list_(pa.int64())), | ||
pa.field("list_str", pa.list_(pa.string())), | ||
pa.field("struct", pa.struct([pa.field("a", pa.int64())])), | ||
pa.field("dict", pa.dictionary(pa.int16(), pa.string())), | ||
pa.field("str_as_dict", pa.string()), | ||
] | ||
) | ||
|
||
return pa.table( | ||
[ | ||
pa.array(range(1000)), | ||
pa.array(range(1000), pa.float32()), | ||
pa.array([str(i) for i in range(1000)]), | ||
pa.array([list(range(i)) for i in range(1000)]), | ||
pa.array([[str(i)] for i in range(1000)]), | ||
pa.array([{"a": i} for i in range(1000)]), | ||
pa.array( | ||
[str(i % 10) for i in range(1000)], | ||
pa.dictionary(pa.int16(), pa.string()), | ||
), | ||
pa.array(["a"] * 500 + ["b"] * 500), | ||
], | ||
schema=schema, | ||
) | ||
|
||
|
||
def write_basic_types(): | ||
path = get_path("basic_types.lance") | ||
with LanceFileWriter(str(path)) as writer: | ||
writer.write_batch(build_basic_types()) | ||
|
||
|
||
def build_large(): | ||
# ~40MB of vector embedding data (10K 1024-float32) | ||
fsl_data = pa.array(range(1024 * 1000 * 10), pa.float32()) | ||
fsls = pa.FixedSizeListArray.from_arrays(fsl_data, 1024) | ||
# ~40 MiB of binary data (10k 4KiB chunks) | ||
bindata = pa.allocate_buffer(1024 * 1000 * 40) | ||
offsets = pa.array( | ||
range(0, (1024 * 1000 * 40) + 4 * 1024, 4 * 1024), pa.int32() | ||
).buffers()[1] | ||
bins = pa.BinaryArray.from_buffers(pa.binary(), 10000, [None, offsets, bindata]) | ||
|
||
schema = pa.schema( | ||
[ | ||
pa.field("int", pa.int32()), | ||
pa.field("fsl", pa.list_(pa.float32())), | ||
pa.field("bin", pa.binary()), | ||
] | ||
) | ||
|
||
return pa.table( | ||
[ | ||
pa.array(range(10000), pa.int32()), | ||
fsls, | ||
bins, | ||
], | ||
schema=schema, | ||
) | ||
|
||
|
||
def write_large(): | ||
path = get_path("large.lance") | ||
with LanceFileWriter(str(path)) as writer: | ||
writer.write_batch(build_large()) | ||
|
||
|
||
if __name__ == "__main__": | ||
write_basic_types() | ||
write_large() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-FileCopyrightText: Copyright The Lance Authors | ||
|
||
import pytest | ||
from lance.file import LanceFileReader | ||
|
||
from .datagen import build_basic_types, build_large, get_path | ||
|
||
|
||
@pytest.mark.forward | ||
def test_scans(): | ||
expected_basic_types = build_basic_types() | ||
actual_basic_types = ( | ||
LanceFileReader(str(get_path("basic_types.lance"))).read_all().to_table() | ||
) | ||
assert actual_basic_types.equals(expected_basic_types) | ||
|
||
expected_large = build_large() | ||
actual_large = LanceFileReader(str(get_path("large.lance"))).read_all().to_table() | ||
assert actual_large.equals(expected_large) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy! ✨