mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
Merge main and align cosine patch with Lance beta.29
This commit is contained in:
+12
-27
@@ -1,5 +1,5 @@
|
||||
[tool.bumpversion]
|
||||
current_version = "0.42.0-beta.25"
|
||||
current_version = "0.42.0-beta.27"
|
||||
parse = """(?x)
|
||||
(?P<major>0|[1-9]\\d*)\\.
|
||||
(?P<minor>0|[1-9]\\d*)\\.
|
||||
@@ -23,31 +23,6 @@ allow_dirty = true
|
||||
commit = true
|
||||
message = "Bump version: {current_version} → {new_version}"
|
||||
commit_args = ""
|
||||
# bump-my-version >=1.4.0 rejects pre_commit_hooks containing shell syntax unless opted in.
|
||||
allow_shell_hooks = true
|
||||
|
||||
# Java maven files
|
||||
pre_commit_hooks = [
|
||||
"""
|
||||
NEW_VERSION="${BVHOOK_NEW_MAJOR}.${BVHOOK_NEW_MINOR}.${BVHOOK_NEW_PATCH}"
|
||||
if [ ! -z "$BVHOOK_NEW_PRE_L" ] && [ ! -z "$BVHOOK_NEW_PRE_N" ]; then
|
||||
NEW_VERSION="${NEW_VERSION}-${BVHOOK_NEW_PRE_L}.${BVHOOK_NEW_PRE_N}"
|
||||
fi
|
||||
echo "Constructed new version: $NEW_VERSION"
|
||||
cd java && mvn versions:set -DnewVersion=$NEW_VERSION && mvn versions:commit
|
||||
|
||||
# Check for any modified but unstaged pom.xml files
|
||||
MODIFIED_POMS=$(git ls-files -m | grep pom.xml)
|
||||
if [ ! -z "$MODIFIED_POMS" ]; then
|
||||
echo "The following pom.xml files were modified but not staged. Adding them now:"
|
||||
echo "$MODIFIED_POMS" | while read -r file; do
|
||||
git add "$file"
|
||||
echo "Added: $file"
|
||||
done
|
||||
fi
|
||||
""",
|
||||
]
|
||||
|
||||
[tool.bumpversion.parts.pre_l]
|
||||
optional_value = "final"
|
||||
values = ["beta", "final"]
|
||||
@@ -87,7 +62,17 @@ filename = "python/Cargo.toml"
|
||||
replace = "\nversion = \"{new_version}\""
|
||||
search = "\nversion = \"{current_version}\""
|
||||
|
||||
# Java documentation
|
||||
# Java Maven coordinates and documentation
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "java/pom.xml"
|
||||
search = "<artifactId>lancedb-parent</artifactId>\n <version>{current_version}</version>"
|
||||
replace = "<artifactId>lancedb-parent</artifactId>\n <version>{new_version}</version>"
|
||||
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "java/lancedb-core/pom.xml"
|
||||
search = "<artifactId>lancedb-parent</artifactId>\n <version>{current_version}</version>"
|
||||
replace = "<artifactId>lancedb-parent</artifactId>\n <version>{new_version}</version>"
|
||||
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "docs/src/java/java.md"
|
||||
replace = "<version>{new_version}</version>"
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
"plugins": [
|
||||
{
|
||||
"name": "lancedb",
|
||||
"source": "./plugins/lancedb",
|
||||
"source": {
|
||||
"source": "github",
|
||||
"repo": "lancedb/lancedb-agent-plugins"
|
||||
},
|
||||
"description": "Write, review, debug, and document LanceDB pipelines in Python and TypeScript that work with both LanceDB Embedded and LanceDB Enterprise.",
|
||||
"version": "0.1.0",
|
||||
"author": {
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.10"
|
||||
python-version: "3.11"
|
||||
cache: "pip"
|
||||
cache-dependency-path: "docs/requirements.txt"
|
||||
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
||||
|
||||
@@ -42,6 +42,12 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
# The workspace-wide Clippy run below builds the PyO3 bindings, whose
|
||||
# minimum supported interpreter is 3.11. Ubuntu 22.04 defaults to 3.10.
|
||||
python-version: "3.11"
|
||||
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
|
||||
with:
|
||||
version: 11.1.1
|
||||
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.10"
|
||||
python-version: "3.11"
|
||||
- name: Add swap for Arm fat LTO
|
||||
if: matrix.config.platform == 'aarch64'
|
||||
shell: bash
|
||||
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
matrix:
|
||||
python-minor-version: ["10", "13"]
|
||||
python-minor-version: ["11", "13"]
|
||||
runs-on: "ubuntu-24.04"
|
||||
defaults:
|
||||
run:
|
||||
@@ -268,7 +268,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.10"
|
||||
python-version: "3.11"
|
||||
# As with Doctest, `pip install -e .` compiles the extension and this job
|
||||
# had no Rust cache, which is most of its ~37 minutes.
|
||||
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
||||
|
||||
Generated
+51
-74
@@ -3885,8 +3885,8 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "fsst"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"rand 0.9.5",
|
||||
@@ -5364,8 +5364,8 @@ checksum = "e037a2e1d8d5fdbd49b16a4ea09d5d6401c1f29eca5ff29d03d3824dba16256a"
|
||||
|
||||
[[package]]
|
||||
name = "lance"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5440,14 +5440,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-arrow"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
"arrow-cast",
|
||||
"arrow-data",
|
||||
"arrow-ipc",
|
||||
"arrow-ord",
|
||||
"arrow-row",
|
||||
"arrow-schema",
|
||||
"arrow-select",
|
||||
"bytemuck",
|
||||
@@ -5460,34 +5462,10 @@ dependencies = [
|
||||
"rand 0.9.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lance-arrow-scalar"
|
||||
version = "59.0.0"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
"arrow-cast",
|
||||
"arrow-data",
|
||||
"arrow-row",
|
||||
"arrow-schema",
|
||||
"half",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lance-arrow-stats"
|
||||
version = "59.0.0"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
"lance-arrow-scalar",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lance-bitpacking"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"crunchy",
|
||||
@@ -5497,8 +5475,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-core"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5536,8 +5514,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datafusion"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5568,8 +5546,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datafusion-exec"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5594,8 +5572,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datagen"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5612,8 +5590,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-derive"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5622,8 +5600,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-encoding"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-arith",
|
||||
"arrow-array",
|
||||
@@ -5657,8 +5635,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-file"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-arith",
|
||||
"arrow-array",
|
||||
@@ -5689,8 +5667,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-geo"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5721,8 +5699,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-index"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5755,7 +5733,6 @@ dependencies = [
|
||||
"itertools 0.14.0",
|
||||
"jieba-rs",
|
||||
"lance-arrow",
|
||||
"lance-arrow-stats",
|
||||
"lance-bitpacking",
|
||||
"lance-core",
|
||||
"lance-datafusion",
|
||||
@@ -5795,8 +5772,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-index-core"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5819,8 +5796,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-io"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5865,8 +5842,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-jsonb"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"ethnum",
|
||||
@@ -5883,7 +5860,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-linalg"
|
||||
version = "15.0.0-beta.28"
|
||||
version = "15.0.0-beta.29"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"argminmax 0.7.1",
|
||||
@@ -5905,8 +5882,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-namespace"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"async-trait",
|
||||
@@ -5920,8 +5897,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-namespace-impls"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5975,8 +5952,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-select"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5990,8 +5967,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-table"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -6032,8 +6009,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-testing"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -6046,8 +6023,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-tokenizer"
|
||||
version = "15.0.0-beta.28"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.28#4e5530c0ed83d3978e35d0e585257ddf438b9cf7"
|
||||
version = "15.0.0-beta.29"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v15.0.0-beta.29#ded121cd9a99dc83040cf41049dc2bd3963241b9"
|
||||
dependencies = [
|
||||
"frostem",
|
||||
"icu_segmenter",
|
||||
@@ -6060,7 +6037,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
@@ -6171,7 +6148,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb-cli"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrow-array",
|
||||
@@ -6214,7 +6191,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb-nodejs"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -6240,7 +6217,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb-python"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
|
||||
+14
-14
@@ -20,20 +20,20 @@ categories = ["database-implementations"]
|
||||
rust-version = "1.95.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
lance = { "version" = "=15.0.0-beta.28", default-features = false, "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-core = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datagen = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-file = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-io = { "version" = "=15.0.0-beta.28", default-features = false, "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-index = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-jsonb = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace-impls = { "version" = "=15.0.0-beta.28", default-features = false, "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-table = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-testing = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datafusion = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-arrow = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance = { "version" = "=15.0.0-beta.29", default-features = false, "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-core = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datagen = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-file = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-io = { "version" = "=15.0.0-beta.29", default-features = false, "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-index = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-jsonb = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace-impls = { "version" = "=15.0.0-beta.29", default-features = false, "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-table = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-testing = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datafusion = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-arrow = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lancedb = { path = "rust/lancedb", default-features = false }
|
||||
ahash = "0.8"
|
||||
anyhow = "1"
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run from the repository root with bump-my-version and packaging installed.
|
||||
set -euo pipefail
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
mkdir -p "$work/repo" "$work/bin"
|
||||
|
||||
# Release tagging must still include Java's versions when Maven cannot update them.
|
||||
cat > "$work/bin/mvn" <<'MOCK'
|
||||
#!/bin/sh
|
||||
echo "Unable to run Maven versions plugin" >&2
|
||||
exit 1
|
||||
MOCK
|
||||
chmod +x "$work/bin/mvn"
|
||||
export PATH="$work/bin:$PATH"
|
||||
|
||||
git ls-files -z .bumpversion.toml ci/bump_version.sh ci/semver_sort.py \
|
||||
nodejs/package.json 'nodejs/npm/*/package.json' nodejs/Cargo.toml \
|
||||
rust/lancedb/Cargo.toml rust/lancedb/cli/Cargo.toml python/Cargo.toml \
|
||||
docs/src/java/java.md java/pom.xml java/lancedb-core/pom.xml |
|
||||
tar --null -T - -cf - | tar -xf - -C "$work/repo"
|
||||
cd "$work/repo"
|
||||
|
||||
# The breaking-change check needs GitHub access and runs after the release tag is set.
|
||||
printf 'pass\n' > ci/check_breaking_changes.py
|
||||
git init --quiet
|
||||
git config user.name "Release test"
|
||||
git config user.email "release-test@example.com"
|
||||
git add .
|
||||
git commit --quiet --message "Release baseline"
|
||||
git tag v0.0.0
|
||||
|
||||
current_version=$(python -c 'import tomllib; print(tomllib.load(open(".bumpversion.toml", "rb"))["tool"]["bumpversion"]["current_version"])')
|
||||
git tag "v$current_version"
|
||||
|
||||
# Verify the current baseline before bumping; stale Java POMs must fail.
|
||||
python - "$current_version" <<'PY'
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
expected = sys.argv[1]
|
||||
ns = {"m": "http://maven.apache.org/POM/4.0.0"}
|
||||
for path, xpath in (
|
||||
("java/pom.xml", "m:version"),
|
||||
("java/lancedb-core/pom.xml", "m:parent/m:version"),
|
||||
):
|
||||
actual = ET.parse(path).getroot().findtext(xpath, namespaces=ns)
|
||||
if actual != expected:
|
||||
raise SystemExit(f"Java baseline mismatch in {path}: expected {expected}, got {actual}")
|
||||
print(f"Java baseline matches {expected} in both POMs")
|
||||
PY
|
||||
|
||||
check_java_release() {
|
||||
local release_type=$1
|
||||
local expected_version=$2
|
||||
bash ci/bump_version.sh "$release_type" false > "$work/bump.log" 2>&1 || {
|
||||
cat "$work/bump.log"
|
||||
return 1
|
||||
}
|
||||
python - "$release_type" "$expected_version" <<'PY'
|
||||
import subprocess
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
release_type, expected_version = sys.argv[1:]
|
||||
case = f"test_java_release_version_matches_tag ({release_type})"
|
||||
tag = subprocess.check_output(["git", "describe", "--tags", "--exact-match", "HEAD"], text=True).strip()
|
||||
assert tag == f"v{expected_version}", f"{case}: expected v{expected_version}, got {tag}"
|
||||
namespace = {"m": "http://maven.apache.org/POM/4.0.0"}
|
||||
for path, version_path in (
|
||||
("java/pom.xml", "m:version"),
|
||||
("java/lancedb-core/pom.xml", "m:parent/m:version"),
|
||||
):
|
||||
content = subprocess.check_output(["git", "show", f"{tag}:{path}"])
|
||||
version = ET.fromstring(content).findtext(version_path, namespaces=namespace)
|
||||
assert version == expected_version, f"{case}: {path}: expected {expected_version}, got {version}"
|
||||
print(f"{case}: passed")
|
||||
PY
|
||||
}
|
||||
|
||||
case "$current_version" in
|
||||
*-beta.*)
|
||||
preview_version="${current_version%.*}.$((${current_version##*.} + 1))"
|
||||
;;
|
||||
*)
|
||||
preview_version="${current_version%.*}.$((${current_version##*.} + 1))-beta.0"
|
||||
;;
|
||||
esac
|
||||
check_java_release preview "$preview_version"
|
||||
check_java_release stable "${preview_version%-beta.*}"
|
||||
@@ -14,7 +14,7 @@ Add the following dependency to your `pom.xml`:
|
||||
<dependency>
|
||||
<groupId>com.lancedb</groupId>
|
||||
<artifactId>lancedb-core</artifactId>
|
||||
<version>0.42.0-beta.25</version>
|
||||
<version>0.42.0-beta.27</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -676,6 +676,8 @@ with BlobReader(read_range, len(payload)) as reader:
|
||||
|
||||
::: lancedb.BlobReader
|
||||
|
||||
::: lancedb.functions.BlobWriter
|
||||
|
||||
::: lancedb.functions.FunctionArtifact
|
||||
|
||||
::: lancedb.functions.FunctionParameter
|
||||
@@ -1520,7 +1522,7 @@ integration = db.create_storage_integration(
|
||||
print(integration.configuration_instructions)
|
||||
```
|
||||
|
||||
Use `SecretReference` to qualify another database or namespace. Sync and async connections use the same options. Secret values are never part of integration metadata. Azure supports service principal client credentials; managed identity, account key and SAS authentication are not integration modes.
|
||||
Use `SecretReference` to qualify another database or namespace. Sync and async connections use the same options. Secret values are never part of integration metadata. Azure supports service principal credentials and storage account access keys.
|
||||
|
||||
The equivalent SQL is:
|
||||
|
||||
@@ -1537,6 +1539,23 @@ SHOW STORAGE INTEGRATIONS;
|
||||
DROP STORAGE INTEGRATION customer_blobs;
|
||||
```
|
||||
|
||||
For Shared Key authorization, store the storage account access key in one
|
||||
Secret and pass its reference as the only credential option:
|
||||
|
||||
```python
|
||||
integration = db.create_storage_integration(
|
||||
"customer_blobs_key",
|
||||
"az://customer-data/raw/",
|
||||
storage_provider="AZURE",
|
||||
azure_storage_account="customeraccount",
|
||||
azure_storage_account_access_key_secret="azure_key",
|
||||
)
|
||||
```
|
||||
|
||||
The equivalent SQL credential option is
|
||||
`STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET = public.azure_key`. Shared
|
||||
Key authorization must be enabled on the Azure storage account.
|
||||
|
||||
Registration returns setup instructions and leaves `access_verified` false. It stores an account-qualified prefix such as `az://customer-data@customeraccount.blob.core.windows.net/raw/`.
|
||||
|
||||
### GCP storage integrations
|
||||
|
||||
@@ -420,13 +420,13 @@ def test_update_using_sql():
|
||||
|
||||
|
||||
def test_merge_matched_update_only():
|
||||
# --8<-- [start:merge_matched_update_only]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:merge_matched_update_only]
|
||||
import pyarrow as pa
|
||||
|
||||
table = db.create_table(
|
||||
@@ -457,13 +457,13 @@ def test_merge_matched_update_only():
|
||||
|
||||
|
||||
def test_insert_if_not_exists():
|
||||
# --8<-- [start:insert_if_not_exists]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:insert_if_not_exists]
|
||||
import pyarrow as pa
|
||||
|
||||
table = db.create_table(
|
||||
@@ -494,13 +494,13 @@ def test_insert_if_not_exists():
|
||||
|
||||
|
||||
def test_merge_update_insert():
|
||||
# --8<-- [start:merge_update_insert]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:merge_update_insert]
|
||||
import pyarrow as pa
|
||||
|
||||
table = db.create_table(
|
||||
@@ -537,13 +537,13 @@ def test_merge_update_insert():
|
||||
|
||||
|
||||
def test_merge_delete_missing_by_source():
|
||||
# --8<-- [start:merge_delete_missing_by_source]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:merge_delete_missing_by_source]
|
||||
import pyarrow as pa
|
||||
|
||||
table = db.create_table(
|
||||
@@ -581,13 +581,13 @@ def test_merge_delete_missing_by_source():
|
||||
|
||||
|
||||
def test_merge_partial_columns():
|
||||
# --8<-- [start:merge_partial_columns]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:merge_partial_columns]
|
||||
import pyarrow as pa
|
||||
|
||||
table = db.create_table(
|
||||
@@ -665,13 +665,13 @@ def test_write_workflow():
|
||||
|
||||
|
||||
def test_append_rows():
|
||||
# --8<-- [start:append_rows]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:append_rows]
|
||||
table = db.create_table("users", [{"id": 1, "name": "Alice"}])
|
||||
table.add([{"id": 2, "name": "Bob"}, {"id": 3, "name": "Charlie"}])
|
||||
rows = sorted(table.search().to_list(), key=lambda row: row["id"])
|
||||
@@ -708,6 +708,7 @@ def test_delete_rows():
|
||||
|
||||
|
||||
def test_add_progress():
|
||||
# --8<-- [start:add_progress]
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
@@ -717,7 +718,6 @@ def test_add_progress():
|
||||
|
||||
with TemporaryDirectory(prefix="lancedb-ingestion-") as uri:
|
||||
db = lancedb.connect(uri)
|
||||
# --8<-- [start:add_progress]
|
||||
table = db.create_table("users", [{"id": 1, "name": "Alice"}])
|
||||
table.add(
|
||||
[{"id": 2, "name": "Bob"}, {"id": 3, "name": "Charlie"}],
|
||||
|
||||
@@ -2,31 +2,32 @@
|
||||
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
|
||||
def test_read_consistency(tmp_path):
|
||||
uri = str(tmp_path)
|
||||
def test_read_consistency():
|
||||
# --8<-- [start:read_consistency]
|
||||
from datetime import timedelta
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import lancedb
|
||||
|
||||
writer = lancedb.connect(uri)
|
||||
table = writer.create_table("documents", [{"id": 1, "text": "first"}])
|
||||
with TemporaryDirectory(prefix="lancedb-consistency-") as uri:
|
||||
writer = lancedb.connect(uri)
|
||||
table = writer.create_table("documents", [{"id": 1, "text": "first"}])
|
||||
|
||||
default_reader = lancedb.connect(uri).open_table("documents")
|
||||
latest_reader = lancedb.connect(
|
||||
uri, read_consistency_interval=timedelta(0)
|
||||
).open_table("documents")
|
||||
default_reader = lancedb.connect(uri).open_table("documents")
|
||||
latest_reader = lancedb.connect(
|
||||
uri, read_consistency_interval=timedelta(0)
|
||||
).open_table("documents")
|
||||
|
||||
table.add([{"id": 2, "text": "second"}])
|
||||
table.add([{"id": 2, "text": "second"}])
|
||||
|
||||
default_count = default_reader.count_rows()
|
||||
latest_count = latest_reader.count_rows()
|
||||
print(f"Default reader: {default_count} rows") # 1
|
||||
print(f"Zero-interval reader: {latest_count} rows") # 2
|
||||
default_count = default_reader.count_rows()
|
||||
latest_count = latest_reader.count_rows()
|
||||
print(f"Default reader: {default_count} rows") # 1
|
||||
print(f"Zero-interval reader: {latest_count} rows") # 2
|
||||
|
||||
default_reader.checkout_latest()
|
||||
refreshed_count = default_reader.count_rows()
|
||||
print(f"After explicit refresh: {refreshed_count} rows") # 2
|
||||
default_reader.checkout_latest()
|
||||
refreshed_count = default_reader.count_rows()
|
||||
print(f"After explicit refresh: {refreshed_count} rows") # 2
|
||||
# --8<-- [end:read_consistency]
|
||||
|
||||
assert default_count == 1
|
||||
|
||||
@@ -294,11 +294,10 @@ evaluation, and how that differs from rotating or revoking it later.
|
||||
## Read and produce blobs {#blobs}
|
||||
|
||||
A Function can bind a [Blob v2 column](/management/table#managed-blobs) and
|
||||
return another blob, including a blob nested inside a struct field, not only
|
||||
at the top level. In row mode, a top-level blob parameter arrives as Python
|
||||
`bytes`, or `None` for a nullable input, after the worker has read the
|
||||
payload. Return bytes and let the destination table store the Managed
|
||||
payload and descriptor.
|
||||
return a Blob v2 value at the top level or inside a struct. In row mode, a
|
||||
top-level blob parameter arrives as Python `bytes`, or `None` for a nullable
|
||||
input, after the worker reads the payload. Use `BlobReader` to read it
|
||||
incrementally.
|
||||
|
||||
This section extracts a frame from a stored video and captions it,
|
||||
continuing as one example across chaining, persisting and incremental reads
|
||||
@@ -322,10 +321,32 @@ frames = db.create_table("frames", [
|
||||
|
||||
### Produce a blob {#produce-blobs}
|
||||
|
||||
Declare blob inputs and outputs explicitly. `extract_frame` reads one frame
|
||||
out of a video at a timestamp and returns it as a JPEG, without loading the
|
||||
whole clip first -- see [Read a blob incrementally](#incremental) below for
|
||||
how the `video: BlobReader` parameter does that:
|
||||
{/*
|
||||
Draft for the streaming Blob output release.
|
||||
|
||||
Use `BlobWriter` during computed column refresh to produce a Blob v2 value in
|
||||
chunks. Register the Function with a Python SDK that exposes `BlobWriter`
|
||||
after upgrading the LanceDB Enterprise server and Function worker images to
|
||||
versions that support streaming Blob output. Keep returning `bytes` with an
|
||||
explicit Blob v2 output schema on deployments without writer support.
|
||||
|
||||
Import `BlobWriter` from `lancedb.functions`. In a scalar Function,
|
||||
`-> BlobWriter` infers a non-nullable Blob v2 output. For a vectorized
|
||||
Function, provide `input_schema` and annotate the return as
|
||||
`list[BlobWriter]` or `tuple[BlobWriter, ...]` to infer one Blob v2 result per
|
||||
row. Return the writers in input row order. Use `BlobWriter.field(...)` in
|
||||
an explicit output schema to mark writer-capable Blob v2 fields in named or
|
||||
nested results.
|
||||
|
||||
Open a writer with `BlobWriter.open()`, pass each chunk to `write()`, and
|
||||
return the sealed writer after leaving its context manager. For plain SQL
|
||||
`SELECT`, use a byte-returning Function within the query's Arrow output
|
||||
limits.
|
||||
*/}
|
||||
|
||||
`extract_frame` reads one frame from a video and returns JPEG bytes. Its
|
||||
explicit output schema declares a Blob v2 result. The `BlobReader` input
|
||||
lets it read the video incrementally. [Read a blob incrementally](#incremental)
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
@@ -365,15 +386,8 @@ fixed-size lists do not support this layout. List-nested values are queryable
|
||||
as descriptors, but `fetch_blobs` and `blob_mode="bytes"` cannot fetch their
|
||||
payloads.
|
||||
|
||||
<Warning>
|
||||
`output_schema=lancedb.blob(...)` is what makes a persisted result Blob v2
|
||||
rather than plain Arrow `binary`. Returning `bytes` from a function whose
|
||||
output type is inferred from a bare annotation, with no explicit
|
||||
`lancedb.blob(...)` output schema, persists as ordinary `binary`: the column
|
||||
still holds the right bytes, but it skips the Managed storage path, descriptor
|
||||
reads, and `fetch_blobs`. Declare it explicitly on every function whose output
|
||||
should be a blob, not just the first one in a chain.
|
||||
</Warning>
|
||||
A bare `bytes` return annotation infers ordinary Arrow `binary`. To store
|
||||
returned bytes as Blob v2, declare `output_schema=lancedb.blob(...)`.
|
||||
|
||||
### Chain a Function on its output {#chain}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ integration's prefix covers it.
|
||||
| --- | --- | --- |
|
||||
| AWS S3 | An IAM role to assume, or a static access key pair | A role needs one extra step outside LanceDB: [trust policy setup](#trust). |
|
||||
| Google Cloud Storage | A service account's JSON key | No role-based alternative. |
|
||||
| Azure Blob Storage | A service principal's tenant, client ID and client secret | All three required together. |
|
||||
| Azure Blob Storage | Three service principal Secrets or one storage account access key Secret | Both modes require the storage account name. |
|
||||
| HuggingFace | An access token | Always required to create an integration. For anonymous access at HuggingFace's default rate limits, register no integration for that prefix instead. |
|
||||
|
||||
Every credential option takes a [Secret](/management/secret) reference,
|
||||
@@ -99,6 +99,11 @@ role-based alternative.
|
||||
|
||||
### Azure Blob Storage {#azure}
|
||||
|
||||
Specify the storage account and choose either service principal credentials or
|
||||
a storage account access key. Reference the values through Secrets.
|
||||
|
||||
#### Service principal
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
CREATE STORAGE INTEGRATION blobs
|
||||
@@ -121,8 +126,48 @@ db.create_storage_integration(
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
All four options are required together; there is no role-based
|
||||
alternative for Azure.
|
||||
#### Storage account access key
|
||||
|
||||
Store the key in a single Secret. Azure must allow Shared Key authorization on
|
||||
the storage account.
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
CREATE STORAGE INTEGRATION blobs_key
|
||||
STORAGE_PROVIDER = 'AZURE'
|
||||
STORAGE_PREFIX = 'az://customer-data/raw/'
|
||||
STORAGE_AZURE_STORAGE_ACCOUNT = 'customeraccount'
|
||||
STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET = azure_key
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Use SQL to create the integration from TypeScript applications.
|
||||
|
||||
{/*
|
||||
Draft for the SDK release with Azure storage account access key support.
|
||||
Publish these examples when the client APIs and Enterprise support ship.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
db.create_storage_integration(
|
||||
"blobs_key", "az://customer-data/raw/",
|
||||
storage_provider="AZURE",
|
||||
azure_storage_account="customeraccount",
|
||||
azure_storage_account_access_key_secret="azure_key",
|
||||
)
|
||||
```
|
||||
```rust
|
||||
use lancedb::storage_integration::{CreateStorageIntegrationRequest, SecretReference};
|
||||
|
||||
let request = CreateStorageIntegrationRequest::azure_with_account_access_key(
|
||||
"az://customer-data/raw/",
|
||||
"customeraccount",
|
||||
SecretReference::new("azure_key"),
|
||||
);
|
||||
let info = db.create_storage_integration("blobs_key", request, &[]).await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
*/}
|
||||
|
||||
### HuggingFace {#huggingface}
|
||||
|
||||
|
||||
@@ -612,12 +612,26 @@ undecorated class, so local tests can create an instance and call it directly.
|
||||
A Function can bind a [Blob v2 column](/management/table#managed-blobs) as
|
||||
input and return another. In row mode, a top-level blob parameter arrives as
|
||||
Python `bytes`, or `None` for a nullable input, after the worker has read
|
||||
the payload; annotate it `BlobReader` instead for seekable, incremental
|
||||
reads that avoid materializing the whole payload first. Return bytes and let
|
||||
the destination table store the Managed payload and descriptor --
|
||||
`output_schema=lancedb.blob(...)` is what makes the result Blob v2 rather
|
||||
than plain Arrow `binary`; a bare annotation persists as ordinary binary
|
||||
instead, skipping the Managed storage path and `fetch_blobs`.
|
||||
the payload. Annotate it `BlobReader` for seekable, incremental reads.
|
||||
For a Function that returns `bytes`, declare
|
||||
`output_schema=lancedb.blob(...)` to store a Blob v2 result. A bare `bytes`
|
||||
return annotation infers ordinary Arrow `binary`.
|
||||
|
||||
{/*
|
||||
Draft for the streaming Blob output release.
|
||||
|
||||
A scalar `BlobWriter` return annotation infers a non-nullable Blob v2
|
||||
output. A vectorized Function with an explicit `input_schema` can infer one
|
||||
Blob v2 per row with `list[BlobWriter]` or `tuple[BlobWriter, ...]`. Use
|
||||
`BlobWriter.field(...)` to declare writer-capable fields in named or nested
|
||||
outputs.
|
||||
|
||||
Use `BlobWriter` for computed column refresh. Register writer-based Functions
|
||||
after the LanceDB Enterprise server and Function worker images support
|
||||
streaming Blob output, using a Python SDK that provides `BlobWriter`. Use
|
||||
byte-returning Functions on earlier deployments and for plain SQL `SELECT`,
|
||||
where results follow the query's Arrow output limits.
|
||||
*/}
|
||||
|
||||
See [Read and produce blobs](/curation/create-function#blobs) for a full
|
||||
example: extracting a frame from a stored video, chaining a second Function
|
||||
|
||||
@@ -1519,6 +1519,12 @@ but following the conventions keeps your tables consistent with Enterprise tooli
|
||||
You can remove columns using the [`drop_columns`](https://lancedb.github.io/lancedb/python/python/#lancedb.table.Table.drop_columns)
|
||||
method in Python, [`dropColumns`](https://lancedb.github.io/lancedb/js/classes/Table/#dropcolumns) in TypeScript/JavaScript, or `drop_columns` in Rust.
|
||||
|
||||
If a data file still stores other columns, the table keeps it and its ordinary
|
||||
Blob v2 sidecar files when you drop a column or add a new one with the same name.
|
||||
Compaction can rewrite the current columns into new data files. Cleanup can
|
||||
reclaim the superseded data files and their sidecars once the applicable retention
|
||||
window has passed and no retained version, including any tagged version, references
|
||||
those files. See [Garbage Collection](/maintenance/cleanup).
|
||||
|
||||
#### Set Up the example table {#schema-set-up-the-example-table-3}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
export const PyAddFromDataset = "import pyarrow as pa\nimport pyarrow.parquet as pq\n\ndata_path = \"input.parquet\"\npq.write_table(pa.table({\"id\": [1, 2], \"name\": [\"Alice\", \"Bob\"]}), data_path)\nimport pyarrow.dataset as ds\n\ndataset = ds.dataset(data_path, format=\"parquet\")\ntable = db.create_table(\"my_table\", schema=dataset.schema, mode=\"overwrite\")\ntable.add(dataset)\n\nprint(\"Rows:\", table.count_rows())\n";
|
||||
|
||||
export const PyAddProgress = "table = db.create_table(\"users\", [{\"id\": 1, \"name\": \"Alice\"}])\ntable.add(\n [{\"id\": 2, \"name\": \"Bob\"}, {\"id\": 3, \"name\": \"Charlie\"}],\n progress=report_progress,\n)\nrows = sorted(table.search().to_list(), key=lambda row: row[\"id\"])\nprint(\"After insertion:\", rows)\n";
|
||||
export const PyAddProgress = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\ndef report_progress(progress):\n print(f\"Rows written: {progress['output_rows']}\")\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n table = db.create_table(\"users\", [{\"id\": 1, \"name\": \"Alice\"}])\n table.add(\n [{\"id\": 2, \"name\": \"Bob\"}, {\"id\": 3, \"name\": \"Charlie\"}],\n progress=report_progress,\n )\n rows = sorted(table.search().to_list(), key=lambda row: row[\"id\"])\n print(\"After insertion:\", rows)\n";
|
||||
|
||||
export const PyAppendRows = "table = db.create_table(\"users\", [{\"id\": 1, \"name\": \"Alice\"}])\ntable.add([{\"id\": 2, \"name\": \"Bob\"}, {\"id\": 3, \"name\": \"Charlie\"}])\nrows = sorted(table.search().to_list(), key=lambda row: row[\"id\"])\nprint(rows)\n";
|
||||
export const PyAppendRows = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n table = db.create_table(\"users\", [{\"id\": 1, \"name\": \"Alice\"}])\n table.add([{\"id\": 2, \"name\": \"Bob\"}, {\"id\": 3, \"name\": \"Charlie\"}])\n rows = sorted(table.search().to_list(), key=lambda row: row[\"id\"])\n print(rows)\n";
|
||||
|
||||
export const PyCreateEmptyTable = "import pyarrow as pa\n\nschema = pa.schema(\n [\n pa.field(\"vector\", pa.list_(pa.float32(), 2)),\n pa.field(\"item\", pa.string()),\n pa.field(\"price\", pa.float32()),\n ]\n)\ntbl = db.create_table(\"test_empty_table\", schema=schema, mode=\"overwrite\")\n\nprint(\"Rows:\", tbl.count_rows())\n";
|
||||
|
||||
@@ -32,15 +32,15 @@ export const PyDeleteRows = "table = db.create_table(\n \"users\",\n [\n
|
||||
|
||||
export const PyDropTable = "# Create a table first\ndata = [{\"vector\": [1.1, 1.2], \"lat\": 45.5}]\ndb.create_table(\"my_table\", data, mode=\"overwrite\")\n\n# Drop the table\ndb.drop_table(\"my_table\")\n";
|
||||
|
||||
export const PyInsertIfNotExists = "import pyarrow as pa\n\ntable = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n)\n\nincoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n)\n\n(table.merge_insert(\"id\").when_not_matched_insert_all().execute(incoming_users))\n\nprint(\"Rows:\", table.count_rows())\n";
|
||||
export const PyInsertIfNotExists = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n import pyarrow as pa\n\n table = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n )\n\n incoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n )\n\n (table.merge_insert(\"id\").when_not_matched_insert_all().execute(incoming_users))\n\n print(\"Rows:\", table.count_rows())\n";
|
||||
|
||||
export const PyMergeDeleteMissingBySource = "import pyarrow as pa\n\ntable = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2, 3],\n \"name\": [\"Alice\", \"Bob\", \"Charlie\"],\n \"login_count\": [10, 20, 5],\n }\n ),\n mode=\"overwrite\",\n)\n\nincoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n)\n\n(\n table.merge_insert(\"id\")\n .when_matched_update_all()\n .when_not_matched_insert_all()\n .when_not_matched_by_source_delete()\n .execute(incoming_users)\n)\n\nprint(\"Rows:\", table.count_rows())\n";
|
||||
export const PyMergeDeleteMissingBySource = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n import pyarrow as pa\n\n table = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2, 3],\n \"name\": [\"Alice\", \"Bob\", \"Charlie\"],\n \"login_count\": [10, 20, 5],\n }\n ),\n mode=\"overwrite\",\n )\n\n incoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n )\n\n (\n table.merge_insert(\"id\")\n .when_matched_update_all()\n .when_not_matched_insert_all()\n .when_not_matched_by_source_delete()\n .execute(incoming_users)\n )\n\n print(\"Rows:\", table.count_rows())\n";
|
||||
|
||||
export const PyMergeMatchedUpdateOnly = "import pyarrow as pa\n\ntable = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n)\n\nincoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n)\n\n(table.merge_insert(\"id\").when_matched_update_all().execute(incoming_users))\n\nprint(\"Rows:\", table.count_rows())\n";
|
||||
export const PyMergeMatchedUpdateOnly = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n import pyarrow as pa\n\n table = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n )\n\n incoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n )\n\n (table.merge_insert(\"id\").when_matched_update_all().execute(incoming_users))\n\n print(\"Rows:\", table.count_rows())\n";
|
||||
|
||||
export const PyMergePartialColumns = "import pyarrow as pa\n\ntable = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n)\n\nincoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n }\n)\n\n(\n table.merge_insert(\"id\")\n .when_matched_update_all()\n .when_not_matched_insert_all()\n .execute(incoming_users)\n)\n\nprint(\"Rows:\", table.count_rows())\n";
|
||||
export const PyMergePartialColumns = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n import pyarrow as pa\n\n table = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n )\n\n incoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n }\n )\n\n (\n table.merge_insert(\"id\")\n .when_matched_update_all()\n .when_not_matched_insert_all()\n .execute(incoming_users)\n )\n\n print(\"Rows:\", table.count_rows())\n";
|
||||
|
||||
export const PyMergeUpdateInsert = "import pyarrow as pa\n\ntable = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n)\n\nincoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n)\n\n(\n table.merge_insert(\"id\")\n .when_matched_update_all()\n .when_not_matched_insert_all()\n .execute(incoming_users)\n)\n\nprint(\"Rows:\", table.count_rows())\n";
|
||||
export const PyMergeUpdateInsert = "from tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-ingestion-\") as uri:\n db = lancedb.connect(uri)\n import pyarrow as pa\n\n table = db.create_table(\n \"users_example\",\n data=pa.table(\n {\n \"id\": [1, 2],\n \"name\": [\"Alice\", \"Bob\"],\n \"login_count\": [10, 20],\n }\n ),\n mode=\"overwrite\",\n )\n\n incoming_users = pa.table(\n {\n \"id\": [2, 3],\n \"name\": [\"Bobby\", \"Charlie\"],\n \"login_count\": [21, 5],\n }\n )\n\n (\n table.merge_insert(\"id\")\n .when_matched_update_all()\n .when_not_matched_insert_all()\n .execute(incoming_users)\n )\n\n print(\"Rows:\", table.count_rows())\n";
|
||||
|
||||
export const PyOpenExistingTable = "# Create a table first\ndata = [{\"vector\": [1.1, 1.2], \"lat\": 45.5, \"long\": -122.7}]\ndb.create_table(\"test_table\", data, mode=\"overwrite\")\n\n# List table names\nprint(db.list_tables().tables)\n\n# Open existing table\ntbl = db.open_table(\"test_table\")\n\nprint(\"Rows:\", tbl.count_rows())\n";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{/* Auto-generated by scripts/mdx_snippets_gen.py. Do not edit manually. */}
|
||||
|
||||
export const PyReadConsistency = "from datetime import timedelta\n\nimport lancedb\n\nwriter = lancedb.connect(uri)\ntable = writer.create_table(\"documents\", [{\"id\": 1, \"text\": \"first\"}])\n\ndefault_reader = lancedb.connect(uri).open_table(\"documents\")\nlatest_reader = lancedb.connect(\n uri, read_consistency_interval=timedelta(0)\n).open_table(\"documents\")\n\ntable.add([{\"id\": 2, \"text\": \"second\"}])\n\ndefault_count = default_reader.count_rows()\nlatest_count = latest_reader.count_rows()\nprint(f\"Default reader: {default_count} rows\") # 1\nprint(f\"Zero-interval reader: {latest_count} rows\") # 2\n\ndefault_reader.checkout_latest()\nrefreshed_count = default_reader.count_rows()\nprint(f\"After explicit refresh: {refreshed_count} rows\") # 2\n";
|
||||
export const PyReadConsistency = "from datetime import timedelta\nfrom tempfile import TemporaryDirectory\n\nimport lancedb\n\nwith TemporaryDirectory(prefix=\"lancedb-consistency-\") as uri:\n writer = lancedb.connect(uri)\n table = writer.create_table(\"documents\", [{\"id\": 1, \"text\": \"first\"}])\n\n default_reader = lancedb.connect(uri).open_table(\"documents\")\n latest_reader = lancedb.connect(\n uri, read_consistency_interval=timedelta(0)\n ).open_table(\"documents\")\n\n table.add([{\"id\": 2, \"text\": \"second\"}])\n\n default_count = default_reader.count_rows()\n latest_count = latest_reader.count_rows()\n print(f\"Default reader: {default_count} rows\") # 1\n print(f\"Zero-interval reader: {latest_count} rows\") # 2\n\n default_reader.checkout_latest()\n refreshed_count = default_reader.count_rows()\n print(f\"After explicit refresh: {refreshed_count} rows\") # 2\n";
|
||||
|
||||
|
||||
@@ -97,9 +97,12 @@ CREATE STORAGE INTEGRATION blobs
|
||||
| `STORAGE_AZURE_TENANT_ID_SECRET` | Secret ref | Entra ID tenant |
|
||||
| `STORAGE_AZURE_CLIENT_ID_SECRET` | Secret ref | service principal client ID |
|
||||
| `STORAGE_AZURE_CLIENT_SECRET_SECRET` | Secret ref | service principal client secret |
|
||||
| `STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET` | Secret ref | storage account access key for Azure Shared Key authorization |
|
||||
|
||||
All four are required together; there is no role-based alternative for
|
||||
Azure.
|
||||
Specify the storage account and choose one credential mode. Service principal
|
||||
authentication requires all three service principal Secret references. Shared
|
||||
Key authentication requires the account access key Secret reference and an Azure
|
||||
storage account that allows Shared Key authorization.
|
||||
|
||||
### GCP {#gcp}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>com.lancedb</groupId>
|
||||
<artifactId>lancedb-parent</artifactId>
|
||||
<version>0.42.0-beta.24</version>
|
||||
<version>0.42.0-beta.27</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.lancedb</groupId>
|
||||
<artifactId>lancedb-parent</artifactId>
|
||||
<version>0.42.0-beta.24</version>
|
||||
<version>0.42.0-beta.27</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>LanceDB Java SDK Parent POM</description>
|
||||
@@ -28,7 +28,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<arrow.version>15.0.0</arrow.version>
|
||||
<lance-core.version>15.0.0-beta.28</lance-core.version>
|
||||
<lance-core.version>15.0.0-beta.29</lance-core.version>
|
||||
<jackson.version>2.18.12</jackson.version>
|
||||
<spotless.skip>false</spotless.skip>
|
||||
<spotless.version>2.30.0</spotless.version>
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "lancedb-nodejs"
|
||||
edition.workspace = true
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
publish = false
|
||||
license.workspace = true
|
||||
description.workspace = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-darwin-arm64",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": ["darwin"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.darwin-arm64.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-arm64-gnu",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": ["linux"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.linux-arm64-gnu.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-arm64-musl",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": ["linux"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.linux-arm64-musl.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-x64-gnu",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": ["linux"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.linux-x64-gnu.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-x64-musl",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": ["linux"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.linux-x64-musl.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-win32-arm64-msvc",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-win32-x64-msvc",
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"os": ["win32"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.win32-x64-msvc.node",
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
"ann"
|
||||
],
|
||||
"private": false,
|
||||
"version": "0.42.0-beta.25",
|
||||
"version": "0.42.0-beta.27",
|
||||
"main": "dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
|
||||
@@ -16,7 +16,7 @@ The Python package is a wrapper around the Rust library, `lancedb`. We use
|
||||
|
||||
To set up your development environment, you will need to install the following:
|
||||
|
||||
1. Python 3.10 or later
|
||||
1. Python 3.11 or later
|
||||
2. Cargo (Rust's package manager). Use [rustup](https://rustup.rs/) to install.
|
||||
3. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lancedb-python"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
description = "Python bindings for LanceDB"
|
||||
@@ -32,7 +32,7 @@ env_logger.workspace = true
|
||||
log.workspace = true
|
||||
# Maturin enables extension-module mode for Python builds. Keeping it out of
|
||||
# Cargo features lets Rust unit tests link against libpython.
|
||||
pyo3 = { version = "0.29", features = ["abi3-py310", "chrono", "uuid"] }
|
||||
pyo3 = { version = "0.29", features = ["abi3-py311", "chrono", "uuid"] }
|
||||
chrono.workspace = true
|
||||
pyo3-async-runtimes = { version = "0.29", features = [
|
||||
"attributes",
|
||||
|
||||
@@ -16,7 +16,7 @@ description = "Embedded database for vector, full-text and hybrid search on Lanc
|
||||
authors = [{ name = "LanceDB Devs", email = "dev@lancedb.com" }]
|
||||
license = { file = "LICENSE" }
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
requires-python = ">=3.11"
|
||||
keywords = [
|
||||
"lance",
|
||||
"vector-search",
|
||||
@@ -33,7 +33,6 @@ classifiers = [
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
@@ -64,7 +63,7 @@ tests = [
|
||||
"polars>=0.19, <=1.32.3",
|
||||
"pyarrow>=16",
|
||||
"pyarrow-stubs>=16.0",
|
||||
"pylance==15.0.0b28",
|
||||
"pylance==15.0.0b29",
|
||||
"requests>=2.31.0",
|
||||
"datafusion>=54,<55",
|
||||
"opentelemetry-sdk>=1.30.0",
|
||||
@@ -73,18 +72,17 @@ dev = [
|
||||
"ruff>=0.3.0",
|
||||
"pre-commit>=3.5.0",
|
||||
"pyright>=1.1.350",
|
||||
'typing-extensions>=4.0.0; python_version < "3.11"',
|
||||
"maturin>=1.10",
|
||||
]
|
||||
docs = ["mkdocs", "mkdocs-jupyter", "mkdocs-material", "mkdocstrings-python"]
|
||||
clip = ["torch", "pillow>=12.1.1", "open-clip-torch"]
|
||||
siglip = ["torch", "pillow>=12.1.1", "transformers>=4.41.0","sentencepiece"]
|
||||
clip = ["torch", "pillow>=13.0.0", "open-clip-torch"]
|
||||
siglip = ["torch", "pillow>=13.0.0", "transformers>=4.41.0","sentencepiece"]
|
||||
embeddings = [
|
||||
"requests>=2.31.0",
|
||||
"openai>=1.6.1",
|
||||
"sentence-transformers>=2.2.0",
|
||||
"torch>=2.0.0",
|
||||
"pillow>=12.1.1",
|
||||
"pillow>=13.0.0",
|
||||
"open-clip-torch>=2.20.0",
|
||||
"cohere>=4.0",
|
||||
"colpali-engine>=0.3.10",
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
"""Streaming Blob output for Enterprise Functions."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pyarrow as pa
|
||||
|
||||
from .schema import blob
|
||||
|
||||
_BLOB_WRITER_METADATA_KEY = b"lance.function.blob_writer"
|
||||
_REFRESH_REQUIRED = (
|
||||
"BlobWriter is available only during a LanceDB Enterprise computed column refresh"
|
||||
)
|
||||
|
||||
|
||||
def _mark_blob_writer(field: pa.Field) -> pa.Field:
|
||||
metadata: dict[bytes | str, bytes | str] = {
|
||||
key: value for key, value in (field.metadata or {}).items()
|
||||
}
|
||||
metadata[_BLOB_WRITER_METADATA_KEY] = b"true"
|
||||
return field.with_metadata(metadata)
|
||||
|
||||
|
||||
class BlobWriter:
|
||||
"""Write one Blob v2 value in chunks during a computed column refresh.
|
||||
|
||||
Annotate a scalar Function's return value with ``BlobWriter`` to declare a
|
||||
Blob v2 result. For named or nested results, use :meth:`field` for each
|
||||
writer-capable field in the output schema. A vectorized Function returns
|
||||
a row-aligned list or tuple of results.
|
||||
|
||||
Open one writer per Blob value. Writes are sequential and block for
|
||||
capacity. Closing the writer seals the result, including an empty Blob.
|
||||
A context manager seals on normal exit and aborts on exceptional exit.
|
||||
A discarded writer still uses one entry in the batch's cumulative
|
||||
descriptor allowance. Explicit writers and implicit uploads of returned
|
||||
``bytes`` share this allowance.
|
||||
|
||||
Return the sealed writer once at its declared Blob v2 output field during
|
||||
the same invocation. Unclosed or reused writers are invalid results.
|
||||
|
||||
The worker provides the implementation when it runs the packaged Function.
|
||||
|
||||
Examples
|
||||
--------
|
||||
```python
|
||||
from lancedb.functions import BlobWriter, function
|
||||
|
||||
@function
|
||||
def render(text: str) -> BlobWriter:
|
||||
with BlobWriter.open() as output:
|
||||
for line in text.splitlines():
|
||||
output.write(line.encode("utf-8"))
|
||||
output.write(b"\\n")
|
||||
return output
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
raise RuntimeError(_REFRESH_REQUIRED)
|
||||
|
||||
@classmethod
|
||||
def open(cls) -> BlobWriter:
|
||||
"""Open a sequential writer for one Blob in the active invocation."""
|
||||
raise RuntimeError(_REFRESH_REQUIRED)
|
||||
|
||||
def write(self, data) -> int:
|
||||
"""Write a bytes-like object and return the accepted byte count."""
|
||||
raise RuntimeError(_REFRESH_REQUIRED)
|
||||
|
||||
def close(self) -> None:
|
||||
"""Seal the Blob so the writer can be returned as a result."""
|
||||
raise RuntimeError(_REFRESH_REQUIRED)
|
||||
|
||||
def __enter__(self) -> BlobWriter:
|
||||
raise RuntimeError(_REFRESH_REQUIRED)
|
||||
|
||||
def __exit__(self, exc_type, exc, traceback) -> None:
|
||||
raise RuntimeError(_REFRESH_REQUIRED)
|
||||
|
||||
@staticmethod
|
||||
def field(name: str, nullable: bool = True) -> pa.Field:
|
||||
"""Declare a writer-capable Blob v2 field in a Function output schema.
|
||||
|
||||
A marked field also accepts ordinary ``bytes`` and, if nullable,
|
||||
``None``. Use this helper for Function output schemas and use
|
||||
[``lancedb.blob``][lancedb.blob] for table schemas.
|
||||
"""
|
||||
return _mark_blob_writer(blob(name, nullable=nullable))
|
||||
@@ -463,6 +463,9 @@ class DBConnection(EnforceOverrides):
|
||||
azure_tenant_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_secret_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_storage_account_access_key_secret: Optional[
|
||||
Union[str, SecretReference]
|
||||
] = None,
|
||||
gcp_credentials_json_secret: Optional[Union[str, SecretReference]] = None,
|
||||
huggingface_token_secret: Optional[Union[str, SecretReference]] = None,
|
||||
exist_ok: bool = False,
|
||||
@@ -2754,6 +2757,9 @@ class LanceDBConnection(DBConnection):
|
||||
azure_tenant_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_secret_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_storage_account_access_key_secret: Optional[
|
||||
Union[str, SecretReference]
|
||||
] = None,
|
||||
gcp_credentials_json_secret: Optional[Union[str, SecretReference]] = None,
|
||||
huggingface_token_secret: Optional[Union[str, SecretReference]] = None,
|
||||
exist_ok: bool = False,
|
||||
@@ -2772,6 +2778,7 @@ class LanceDBConnection(DBConnection):
|
||||
azure_tenant_id_secret=azure_tenant_id_secret,
|
||||
azure_client_id_secret=azure_client_id_secret,
|
||||
azure_client_secret_secret=azure_client_secret_secret,
|
||||
azure_storage_account_access_key_secret=azure_storage_account_access_key_secret,
|
||||
gcp_credentials_json_secret=gcp_credentials_json_secret,
|
||||
huggingface_token_secret=huggingface_token_secret,
|
||||
exist_ok=exist_ok,
|
||||
@@ -4269,6 +4276,9 @@ class AsyncConnection(object):
|
||||
azure_tenant_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_secret_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_storage_account_access_key_secret: Optional[
|
||||
Union[str, SecretReference]
|
||||
] = None,
|
||||
gcp_credentials_json_secret: Optional[Union[str, SecretReference]] = None,
|
||||
huggingface_token_secret: Optional[Union[str, SecretReference]] = None,
|
||||
exist_ok: bool = False,
|
||||
@@ -4279,7 +4289,8 @@ class AsyncConnection(object):
|
||||
``namespace_path`` follows Secret naming rules. A SecretReference can name
|
||||
another database; a string names a root Secret in this database.
|
||||
For Azure, set ``storage_provider="AZURE"``, ``azure_storage_account``,
|
||||
and Secret references for tenant ID, client ID and client secret.
|
||||
and either ``azure_storage_account_access_key_secret`` or the three
|
||||
Secret references for tenant ID, client ID and client secret.
|
||||
For GCP, set ``storage_provider="GCP"`` and ``gcp_credentials_json_secret``
|
||||
to a Secret containing the application credentials JSON file content.
|
||||
For Hugging Face, set ``storage_provider="HUGGINGFACE"`` and
|
||||
@@ -4291,11 +4302,14 @@ class AsyncConnection(object):
|
||||
integration exists, preserving its provider, prefix and credential
|
||||
bindings. Existing names are errors by default.
|
||||
"""
|
||||
azure_options = (
|
||||
azure_service_principal = (
|
||||
azure_tenant_id_secret,
|
||||
azure_client_id_secret,
|
||||
azure_client_secret_secret,
|
||||
)
|
||||
azure_options = azure_service_principal + (
|
||||
azure_storage_account_access_key_secret,
|
||||
)
|
||||
if storage_provider != "HUGGINGFACE" and huggingface_token_secret is not None:
|
||||
raise ValueError(
|
||||
"Hugging Face options require storage_provider HUGGINGFACE"
|
||||
@@ -4331,12 +4345,17 @@ class AsyncConnection(object):
|
||||
):
|
||||
raise ValueError("GCP integrations cannot contain AWS or Azure options")
|
||||
elif storage_provider == "AZURE":
|
||||
if not azure_storage_account or any(
|
||||
value is None for value in azure_options
|
||||
):
|
||||
if not azure_storage_account:
|
||||
raise ValueError("Azure integrations require azure_storage_account")
|
||||
valid_credentials = (
|
||||
all(value is None for value in azure_service_principal)
|
||||
if azure_storage_account_access_key_secret is not None
|
||||
else all(value is not None for value in azure_service_principal)
|
||||
)
|
||||
if not valid_credentials:
|
||||
raise ValueError(
|
||||
"Azure requires a storage account and "
|
||||
"all three credential Secret references"
|
||||
"Specify either azure_storage_account_access_key_secret or "
|
||||
"all three Azure service principal Secret references"
|
||||
)
|
||||
if any(
|
||||
value is not None
|
||||
@@ -4393,6 +4412,9 @@ class AsyncConnection(object):
|
||||
"azure_tenant_id_secret": reference(azure_tenant_id_secret),
|
||||
"azure_client_id_secret": reference(azure_client_id_secret),
|
||||
"azure_client_secret_secret": reference(azure_client_secret_secret),
|
||||
"azure_storage_account_access_key_secret": reference(
|
||||
azure_storage_account_access_key_secret
|
||||
),
|
||||
"gcp_credentials_json_secret": reference(gcp_credentials_json_secret),
|
||||
"huggingface_token_secret": reference(huggingface_token_secret),
|
||||
"aws_access_key_id_secret": reference(aws_access_key_id_secret),
|
||||
|
||||
@@ -63,6 +63,7 @@ from pydantic import (
|
||||
from .schema import blob as _blob_field
|
||||
from .schema import is_blob_v2_field as _is_blob_v2_field
|
||||
from ._blob_reader import BlobReader
|
||||
from ._blob_writer import BlobWriter, _BLOB_WRITER_METADATA_KEY, _mark_blob_writer
|
||||
from ._lancedb import _validate_conda_requirement
|
||||
from .secrets import EnvVarSecret
|
||||
from .resources import _validate_gpu_class_name
|
||||
@@ -330,17 +331,27 @@ class FunctionResultField(_OpenRemoteValue):
|
||||
nullable: bool
|
||||
|
||||
|
||||
class _BlobWriterFieldStep(_RemoteValue):
|
||||
field: str
|
||||
|
||||
|
||||
_BlobWriterPath = tuple[Union[_BlobWriterFieldStep, Literal["item"]], ...]
|
||||
|
||||
|
||||
class FunctionOutput(_OpenRemoteValue):
|
||||
"""Scalar or ordered named-struct output; unknown kinds remain decodable.
|
||||
|
||||
A scalar output may be nullable. A named-struct output has no top-level
|
||||
nullability; its fields carry their own flags.
|
||||
nullability; its fields carry their own flags. Writer-capable outputs
|
||||
carry the paths of the declared Blob v2 leaves and use the corresponding
|
||||
``scalar_blob_writer`` or ``named_struct_blob_writer`` kind.
|
||||
"""
|
||||
|
||||
kind: str
|
||||
arrow_type: Optional[str] = None
|
||||
nullable: Optional[bool] = None
|
||||
fields: tuple[FunctionResultField, ...] = ()
|
||||
blob_writer_paths: tuple[_BlobWriterPath, ...] = ()
|
||||
|
||||
|
||||
class SecretReference(_RemoteValue):
|
||||
@@ -1069,7 +1080,7 @@ class FunctionApplication(_OpenRemoteValue):
|
||||
|
||||
def rename(self, *, columns: Mapping[str, str]) -> FunctionApplication:
|
||||
"""Return a copy with result-field to table-column aliases."""
|
||||
if self.output.kind != "named_struct":
|
||||
if self.output.kind not in ("named_struct", "named_struct_blob_writer"):
|
||||
raise ValueError("rename(columns=...) requires a named-struct application")
|
||||
result_fields = {field.name for field in self.output.fields}
|
||||
unknown = set(columns) - result_fields
|
||||
@@ -1496,32 +1507,38 @@ def _grammar_list_item(data_type: pa.DataType) -> Optional[str]:
|
||||
return _grammar_arrow_type(child.type)
|
||||
|
||||
|
||||
def _validate_exact_arrow_field(field: pa.Field) -> None:
|
||||
def _validate_exact_arrow_field(
|
||||
field: pa.Field, *, allow_blob_writer: bool = False
|
||||
) -> None:
|
||||
if not field.name:
|
||||
raise TypeError(
|
||||
"unsupported Arrow type for Function signature: field names "
|
||||
"must not be empty"
|
||||
)
|
||||
if _is_blob_v2_field(field):
|
||||
metadata = field.metadata or {}
|
||||
is_blob = _is_blob_v2_field(field)
|
||||
if allow_blob_writer and _BLOB_WRITER_METADATA_KEY in metadata:
|
||||
if not is_blob or metadata[_BLOB_WRITER_METADATA_KEY] != b"true":
|
||||
raise TypeError("BlobWriter output requires a Blob v2 field marked true")
|
||||
metadata = {
|
||||
key: value
|
||||
for key, value in metadata.items()
|
||||
if key != _BLOB_WRITER_METADATA_KEY
|
||||
}
|
||||
if is_blob:
|
||||
if not _has_supported_blob_v2_layout(field):
|
||||
raise TypeError(
|
||||
"unsupported Arrow type for Function signature: lance.blob.v2 "
|
||||
f"requires a supported Blob storage layout, got {field}"
|
||||
)
|
||||
metadata = {
|
||||
(key.decode() if isinstance(key, bytes) else key): (
|
||||
value.decode() if isinstance(value, bytes) else value
|
||||
)
|
||||
for key, value in (field.metadata or {}).items()
|
||||
}
|
||||
if metadata and metadata != {
|
||||
_ARROW_EXTENSION_NAME_KEY: _BLOB_V2_EXTENSION_NAME
|
||||
_ARROW_EXTENSION_NAME_KEY.encode(): _BLOB_V2_EXTENSION_NAME.encode()
|
||||
}:
|
||||
raise TypeError(
|
||||
"unsupported Arrow type for Function signature: lance.blob.v2 "
|
||||
"field metadata must contain only its canonical extension marker"
|
||||
)
|
||||
elif field.metadata:
|
||||
elif metadata:
|
||||
raise TypeError(
|
||||
"unsupported Arrow type for Function signature: field metadata "
|
||||
f"is not supported, got {field}"
|
||||
@@ -1580,7 +1597,7 @@ def _has_supported_blob_v2_layout(field: pa.Field) -> bool:
|
||||
|
||||
def _canonical_arrow_field(field: pa.Field, *, collection_blobs: bool = False) -> str:
|
||||
"""``collection_blobs`` admits Blob v2 under a list, which only outputs support."""
|
||||
_validate_exact_arrow_field(field)
|
||||
_validate_exact_arrow_field(field, allow_blob_writer=collection_blobs)
|
||||
if _is_blob_v2_field(field):
|
||||
return _FUNCTION_BLOB_V2_TYPE
|
||||
return _canonical_arrow_type(field.type, collection_blobs=collection_blobs)
|
||||
@@ -1640,10 +1657,11 @@ def _exact_arrow_field(
|
||||
inside_collection: bool = False,
|
||||
collection_blobs: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
_validate_exact_arrow_field(field)
|
||||
if _is_blob_v2_field(field):
|
||||
if inside_collection and not collection_blobs:
|
||||
raise TypeError(_NESTED_BLOB_COLLECTION_ERROR)
|
||||
is_blob = _is_blob_v2_field(field)
|
||||
if is_blob and inside_collection and not collection_blobs:
|
||||
raise TypeError(_NESTED_BLOB_COLLECTION_ERROR)
|
||||
_validate_exact_arrow_field(field, allow_blob_writer=collection_blobs)
|
||||
if is_blob:
|
||||
return {
|
||||
"name": field.name,
|
||||
"nullable": field.nullable,
|
||||
@@ -1914,6 +1932,106 @@ def _callable_parameters(function: Callable[..., Any]) -> tuple[inspect.Paramete
|
||||
return parameters
|
||||
|
||||
|
||||
def _uses_blob_writer(annotation: Any) -> bool:
|
||||
return annotation is BlobWriter or any(
|
||||
_uses_blob_writer(argument) for argument in get_args(annotation)
|
||||
)
|
||||
|
||||
|
||||
def _annotated_blob_writer_field(
|
||||
annotation: Any, name: str, field: Optional[pa.Field] = None
|
||||
) -> pa.Field:
|
||||
"""Infer a writer-bearing field or mark the matching leaf in an explicit field."""
|
||||
nullable = False
|
||||
arrow_type = None
|
||||
while True:
|
||||
origin = get_origin(annotation)
|
||||
if origin is Annotated:
|
||||
annotation, *metadata = get_args(annotation)
|
||||
types_ = [value for value in metadata if isinstance(value, pa.DataType)]
|
||||
if len(types_) != 1:
|
||||
raise TypeError(
|
||||
"Annotated Function types require exactly one PyArrow DataType"
|
||||
)
|
||||
if arrow_type is None:
|
||||
arrow_type = types_[0]
|
||||
elif origin in (Union, types.UnionType):
|
||||
arguments = get_args(annotation)
|
||||
branches = tuple(arg for arg in arguments if arg is not type(None))
|
||||
nullable |= len(branches) != len(arguments)
|
||||
if len(branches) == 1:
|
||||
(annotation,) = branches
|
||||
elif frozenset(branches) == {BlobWriter, bytes}:
|
||||
annotation = BlobWriter
|
||||
else:
|
||||
raise TypeError(f"unsupported union annotation: {annotation!r}")
|
||||
else:
|
||||
break
|
||||
|
||||
if field is None and arrow_type is not None:
|
||||
field = pa.field(name, arrow_type, nullable=nullable)
|
||||
if annotation is BlobWriter:
|
||||
if field is None:
|
||||
return BlobWriter.field(name, nullable=nullable)
|
||||
if not _is_blob_v2_field(field):
|
||||
raise TypeError("BlobWriter output requires a Blob v2 field")
|
||||
_validate_exact_arrow_field(field, allow_blob_writer=True)
|
||||
return _mark_blob_writer(field)
|
||||
if get_origin(annotation) is list:
|
||||
(element,) = get_args(annotation)
|
||||
if field is None:
|
||||
child = _annotated_blob_writer_field(element, "item")
|
||||
return pa.field(name, pa.list_(child), nullable=nullable)
|
||||
if not (pa.types.is_list(field.type) or pa.types.is_large_list(field.type)):
|
||||
raise TypeError("a list of BlobWriter values requires a list output field")
|
||||
child = field.type.value_field
|
||||
child = _annotated_blob_writer_field(element, child.name, child)
|
||||
list_type = pa.large_list if pa.types.is_large_list(field.type) else pa.list_
|
||||
return field.with_type(list_type(child))
|
||||
raise TypeError(
|
||||
"BlobWriter return annotations require a BlobWriter or list of BlobWriter "
|
||||
"values. Use BlobWriter.field in the output schema for named results."
|
||||
)
|
||||
|
||||
|
||||
def _writer_annotation_output(annotation, output_schema, *, vectorized: bool):
|
||||
if vectorized:
|
||||
arguments = get_args(annotation)
|
||||
origin = get_origin(annotation)
|
||||
if origin is list and len(arguments) == 1:
|
||||
(annotation,) = arguments
|
||||
elif origin is tuple and len(arguments) == 2 and arguments[1] is Ellipsis:
|
||||
annotation = arguments[0]
|
||||
else:
|
||||
raise TypeError(
|
||||
"vectorized BlobWriter Functions must annotate a row-aligned list "
|
||||
"or tuple of results"
|
||||
)
|
||||
if output_schema is None:
|
||||
return _annotated_blob_writer_field(annotation, "result")
|
||||
if isinstance(output_schema, pa.DataType):
|
||||
output_schema = pa.field("result", output_schema, nullable=False)
|
||||
if not isinstance(output_schema, pa.Field):
|
||||
raise TypeError("use BlobWriter.field in the output schema for named results")
|
||||
return _annotated_blob_writer_field(annotation, output_schema.name, output_schema)
|
||||
|
||||
|
||||
def _blob_writer_paths(field: pa.Field) -> tuple[_BlobWriterPath, ...]:
|
||||
if _is_blob_v2_field(field):
|
||||
return ((),) if _BLOB_WRITER_METADATA_KEY in (field.metadata or {}) else ()
|
||||
if pa.types.is_struct(field.type):
|
||||
return tuple(
|
||||
(_BlobWriterFieldStep(field=child.name), *path)
|
||||
for child in field.type
|
||||
for path in _blob_writer_paths(child)
|
||||
)
|
||||
if pa.types.is_list(field.type) or pa.types.is_large_list(field.type):
|
||||
return tuple(
|
||||
("item", *path) for path in _blob_writer_paths(field.type.value_field)
|
||||
)
|
||||
return ()
|
||||
|
||||
|
||||
def _function_output(output: pa.DataType | pa.Field | pa.Schema) -> FunctionOutput:
|
||||
if isinstance(output, pa.Schema):
|
||||
if output.metadata:
|
||||
@@ -1924,7 +2042,7 @@ def _function_output(output: pa.DataType | pa.Field | pa.Schema) -> FunctionOutp
|
||||
and not _is_blob_v2_field(output)
|
||||
and pa.types.is_struct(output.type)
|
||||
):
|
||||
_validate_exact_arrow_field(output)
|
||||
_validate_exact_arrow_field(output, allow_blob_writer=True)
|
||||
if output.nullable:
|
||||
raise ValueError("Function output must be non-nullable")
|
||||
fields = tuple(output.type)
|
||||
@@ -1940,32 +2058,39 @@ def _function_output(output: pa.DataType | pa.Field | pa.Schema) -> FunctionOutp
|
||||
raise TypeError(
|
||||
"output_schema must be a PyArrow DataType, Field, or Schema"
|
||||
)
|
||||
_validate_exact_arrow_field(field)
|
||||
arrow_type = _canonical_arrow_field(field, collection_blobs=True)
|
||||
if field.nullable and _is_blob_v2_field(field):
|
||||
raise ValueError("Blob v2 Function output must be non-nullable")
|
||||
paths = _blob_writer_paths(field)
|
||||
return FunctionOutput(
|
||||
kind="scalar",
|
||||
arrow_type=_canonical_arrow_field(field, collection_blobs=True),
|
||||
kind="scalar_blob_writer" if paths else "scalar",
|
||||
arrow_type=arrow_type,
|
||||
nullable=field.nullable,
|
||||
blob_writer_paths=paths,
|
||||
)
|
||||
|
||||
if not fields:
|
||||
raise ValueError("named-struct Function output must contain at least one field")
|
||||
for field in fields:
|
||||
_validate_exact_arrow_field(field)
|
||||
names = [field.name for field in fields]
|
||||
if len(set(names)) != len(names):
|
||||
raise ValueError("Function output field names must be unique")
|
||||
results = tuple(
|
||||
FunctionResultField(
|
||||
name=field.name,
|
||||
arrow_type=_canonical_arrow_field(field, collection_blobs=True),
|
||||
nullable=field.nullable,
|
||||
)
|
||||
for field in fields
|
||||
)
|
||||
paths = tuple(
|
||||
(_BlobWriterFieldStep(field=field.name), *path)
|
||||
for field in fields
|
||||
for path in _blob_writer_paths(field)
|
||||
)
|
||||
return FunctionOutput(
|
||||
kind="named_struct",
|
||||
fields=tuple(
|
||||
FunctionResultField(
|
||||
name=field.name,
|
||||
arrow_type=_canonical_arrow_field(field, collection_blobs=True),
|
||||
nullable=field.nullable,
|
||||
)
|
||||
for field in fields
|
||||
),
|
||||
kind="named_struct_blob_writer" if paths else "named_struct",
|
||||
fields=results,
|
||||
blob_writer_paths=paths,
|
||||
)
|
||||
|
||||
|
||||
@@ -1987,6 +2112,8 @@ def _infer_signature(
|
||||
|
||||
def input_parameter(field):
|
||||
annotation = annotations.get(field.name)
|
||||
if _uses_blob_writer(annotation):
|
||||
raise TypeError("BlobWriter is only supported in Function outputs")
|
||||
if get_origin(annotation) in (Union, types.UnionType):
|
||||
choices = [
|
||||
value for value in get_args(annotation) if value is not type(None)
|
||||
@@ -2042,10 +2169,17 @@ def _infer_signature(
|
||||
missing.append("return")
|
||||
if missing:
|
||||
raise TypeError(f"missing Function annotations: {missing!r}")
|
||||
return_annotation = annotations.get("return")
|
||||
if _uses_blob_writer(return_annotation):
|
||||
output_schema = _writer_annotation_output(
|
||||
return_annotation,
|
||||
output_schema,
|
||||
vectorized=_is_vectorized_callable(function, method=method),
|
||||
)
|
||||
if output_schema is not None:
|
||||
output = _function_output(output_schema)
|
||||
else:
|
||||
output_type, output_nullable = _annotation_type(annotations["return"])
|
||||
output_type, output_nullable = _annotation_type(return_annotation)
|
||||
output = _function_output(
|
||||
pa.field("result", output_type, nullable=output_nullable)
|
||||
)
|
||||
@@ -2578,6 +2712,25 @@ def _module_locations_for_name(module_name: str) -> tuple[str, ...]:
|
||||
return ()
|
||||
|
||||
|
||||
def _blob_writer_annotation_source(annotation: Any, writer_name: str) -> str:
|
||||
if annotation is BlobWriter:
|
||||
return writer_name
|
||||
if annotation is type(None):
|
||||
return "None"
|
||||
if annotation is bytes:
|
||||
return "bytes"
|
||||
if annotation is Ellipsis:
|
||||
return "..."
|
||||
origin = get_origin(annotation)
|
||||
arguments = get_args(annotation)
|
||||
if origin is Annotated:
|
||||
return _blob_writer_annotation_source(arguments[0], writer_name)
|
||||
elements = [_blob_writer_annotation_source(arg, writer_name) for arg in arguments]
|
||||
if origin in (Union, types.UnionType):
|
||||
return " | ".join(elements)
|
||||
return f"{origin.__name__}[{', '.join(elements)}]"
|
||||
|
||||
|
||||
class _SourcePackager:
|
||||
"""Builds the entry module of a Function artifact.
|
||||
|
||||
@@ -2621,10 +2774,10 @@ class _SourcePackager:
|
||||
"@function cannot package functions that capture closure values"
|
||||
)
|
||||
namespace = _definition_namespace(target)
|
||||
reader_name = (
|
||||
self._blob_annotations(definition, signature, namespace)
|
||||
blob_bindings = (
|
||||
self._blob_annotations(target, definition, signature, namespace)
|
||||
if signature is not None
|
||||
else None
|
||||
else {}
|
||||
)
|
||||
source = ast.unparse(definition)
|
||||
references = _module_references(f"{_SOURCE_HEADER}\n\n{source}\n")
|
||||
@@ -2649,8 +2802,8 @@ class _SourcePackager:
|
||||
self._warn_unshipped_direct_imports(definition)
|
||||
self._packaged.add(id(target))
|
||||
self._claim(target.__name__, ("definition", id(target)))
|
||||
if reader_name is not None:
|
||||
self._bind(reader_name, BlobReader, definition=definition)
|
||||
for name, blob_type in blob_bindings.items():
|
||||
self._bind(name, blob_type, definition=definition)
|
||||
unresolved = []
|
||||
for name in sorted(references):
|
||||
if name == target.__name__:
|
||||
@@ -2673,19 +2826,19 @@ class _SourcePackager:
|
||||
|
||||
def _blob_annotations(
|
||||
self,
|
||||
target: Any,
|
||||
definition: Union[ast.FunctionDef, ast.ClassDef],
|
||||
signature: FunctionSignature,
|
||||
namespace: Mapping[str, Any],
|
||||
) -> Optional[str]:
|
||||
"""Bind reader inputs to the worker type, including postponed aliases."""
|
||||
) -> dict[str, type]:
|
||||
"""Bind Blob annotations to worker types, including postponed aliases."""
|
||||
readers = {
|
||||
parameter.name: parameter
|
||||
for parameter in signature.inputs
|
||||
if parameter.blob_access == "reader"
|
||||
}
|
||||
if not readers:
|
||||
return None
|
||||
call = definition
|
||||
if not readers and not signature.output.blob_writer_paths:
|
||||
return {}
|
||||
if isinstance(definition, ast.ClassDef):
|
||||
call = next(
|
||||
(
|
||||
@@ -2695,19 +2848,47 @@ class _SourcePackager:
|
||||
),
|
||||
None,
|
||||
)
|
||||
if call is None:
|
||||
return None
|
||||
# Avoid shadowing globals used by the body or other packaged definitions.
|
||||
name = "_lance_blob_reader"
|
||||
while name in namespace or name in self._names or name == definition.name:
|
||||
name += "_"
|
||||
for argument in (*call.args.args, *call.args.kwonlyargs):
|
||||
if argument.arg in readers:
|
||||
annotation = name
|
||||
if readers[argument.arg].nullable:
|
||||
annotation += " | None"
|
||||
argument.annotation = ast.parse(annotation, mode="eval").body
|
||||
return name
|
||||
if call is None:
|
||||
return {}
|
||||
else:
|
||||
call = definition
|
||||
|
||||
def alias(name: str) -> str:
|
||||
# Avoid shadowing globals used by the body or other definitions.
|
||||
while name in namespace or name in self._names or name == definition.name:
|
||||
name += "_"
|
||||
return name
|
||||
|
||||
bindings = {}
|
||||
if readers:
|
||||
name = alias("_lance_blob_reader")
|
||||
for argument in (*call.args.args, *call.args.kwonlyargs):
|
||||
if argument.arg in readers:
|
||||
annotation = name
|
||||
if readers[argument.arg].nullable:
|
||||
annotation += " | None"
|
||||
argument.annotation = ast.parse(annotation, mode="eval").body
|
||||
bindings[name] = BlobReader
|
||||
if signature.output.blob_writer_paths:
|
||||
method = inspect.isclass(target)
|
||||
callable_ = _class_call(target) if method else target
|
||||
annotations = get_type_hints(callable_, include_extras=True)
|
||||
if _is_vectorized_callable(callable_, method=method):
|
||||
name = alias("_lance_arrow")
|
||||
for argument in (*call.args.args, *call.args.kwonlyargs):
|
||||
arrow_type = annotations.get(argument.arg)
|
||||
if arrow_type is pa.Array or arrow_type is pa.RecordBatch:
|
||||
argument.annotation = ast.parse(
|
||||
f"{name}.{arrow_type.__name__}", mode="eval"
|
||||
).body
|
||||
bindings[name] = pa
|
||||
return_type = annotations.get("return")
|
||||
if _uses_blob_writer(return_type):
|
||||
name = alias("_lance_blob_writer")
|
||||
annotation = _blob_writer_annotation_source(return_type, name)
|
||||
call.returns = ast.parse(annotation, mode="eval").body
|
||||
bindings[name] = BlobWriter
|
||||
return bindings
|
||||
|
||||
def _claim(self, name: str, meaning: Any) -> None:
|
||||
claimed = self._names.setdefault(name, meaning)
|
||||
@@ -2751,8 +2932,8 @@ class _SourcePackager:
|
||||
approved = _approved_global_namespace_binding(definition, name, value)
|
||||
if approved is not None:
|
||||
return approved
|
||||
if value is BlobReader:
|
||||
return f"from lance_blob import BlobReader as {name}"
|
||||
if value is BlobReader or value is BlobWriter:
|
||||
return f"from lance_blob import {value.__name__} as {name}"
|
||||
if isinstance(value, types.ModuleType):
|
||||
if value.__name__.split(".")[0] in _NAMESPACE_MODULES:
|
||||
raise _namespace_import_error([value.__name__])
|
||||
@@ -3699,9 +3880,10 @@ def function(
|
||||
----------
|
||||
function : function or class, optional
|
||||
The synchronous callable, or the class whose instances are called. For
|
||||
a function, annotate every parameter as ``pyarrow.Array`` to opt into
|
||||
vectorized execution; a matching return annotation documents that the
|
||||
callable returns an Arrow array.
|
||||
a function, annotate every parameter as ``pyarrow.Array`` or a single
|
||||
parameter as ``pyarrow.RecordBatch`` to opt into vectorized execution.
|
||||
A vectorized Function using ``BlobWriter`` returns a row-aligned list
|
||||
or tuple of results.
|
||||
name : str, optional
|
||||
The remote Function name. Defaults to the callable name.
|
||||
Must start with an ASCII letter or underscore and contain only ASCII
|
||||
@@ -3717,8 +3899,9 @@ def function(
|
||||
a map key must be non-nullable utf8 and its value field keeps the
|
||||
declared nullability. Temporal fields use canonical Arrow JSON; the
|
||||
microsecond/no-timezone case keeps the legacy timestamp/duration shape.
|
||||
Required for batch annotations. When omitted, the output is inferred
|
||||
from the return annotation.
|
||||
Required for batch annotations unless the return annotation declares
|
||||
a row-aligned sequence of ``BlobWriter`` results. When omitted, the
|
||||
output is inferred from the return annotation.
|
||||
pip : sequence of str, optional
|
||||
Pip requirements for the remote environment. Syntax is validated at
|
||||
decoration time, including extras and environment markers. Named direct
|
||||
@@ -3892,6 +4075,14 @@ def function(
|
||||
declared nullability. Use :func:`lancedb.blob` in the explicit schemas;
|
||||
plain ``pyarrow.large_binary()`` does not carry Blob v2 semantics.
|
||||
|
||||
For a streaming Blob v2 result, annotate a scalar return with
|
||||
[``BlobWriter``][lancedb.functions.BlobWriter], or annotate a vectorized
|
||||
return with ``list[BlobWriter]`` or ``tuple[BlobWriter, ...]``. To declare a
|
||||
writer in a named or nested output, use ``BlobWriter.field(...)`` in the
|
||||
explicit output schema. Writer-capable Functions run during computed
|
||||
column refresh. Plain SQL ``SELECT`` continues to support byte-returning
|
||||
Functions under its Arrow output limits.
|
||||
|
||||
A Blob v2 field may sit at the top level or inside a struct in inputs and
|
||||
outputs. Only outputs may nest it in a list or large list (for example
|
||||
``pa.list_(lancedb.blob("item"))``, returned as a list of ``bytes``);
|
||||
@@ -3935,6 +4126,7 @@ def function(
|
||||
__all__ = [
|
||||
"AssignmentMapping",
|
||||
"ApplicationInput",
|
||||
"BlobWriter",
|
||||
"FunctionApplication",
|
||||
"FunctionArtifact",
|
||||
"FunctionArtifactContent",
|
||||
|
||||
@@ -62,7 +62,7 @@ from ._blob import (
|
||||
from .types import BlobMode, QueryProjection
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import sys
|
||||
from typing import Self
|
||||
|
||||
import PIL
|
||||
import polars as pl
|
||||
@@ -77,11 +77,6 @@ if TYPE_CHECKING:
|
||||
from .pydantic import LanceModel
|
||||
from .table import AsyncTable, Table
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import Self
|
||||
else:
|
||||
from typing_extensions import Self
|
||||
|
||||
T = TypeVar("T", bound="LanceModel")
|
||||
|
||||
|
||||
|
||||
@@ -1150,6 +1150,9 @@ class RemoteDBConnection(DBConnection):
|
||||
azure_tenant_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_id_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_client_secret_secret: Optional[Union[str, SecretReference]] = None,
|
||||
azure_storage_account_access_key_secret: Optional[
|
||||
Union[str, SecretReference]
|
||||
] = None,
|
||||
gcp_credentials_json_secret: Optional[Union[str, SecretReference]] = None,
|
||||
huggingface_token_secret: Optional[Union[str, SecretReference]] = None,
|
||||
exist_ok: bool = False,
|
||||
@@ -1168,6 +1171,7 @@ class RemoteDBConnection(DBConnection):
|
||||
azure_tenant_id_secret=azure_tenant_id_secret,
|
||||
azure_client_id_secret=azure_client_id_secret,
|
||||
azure_client_secret_secret=azure_client_secret_secret,
|
||||
azure_storage_account_access_key_secret=azure_storage_account_access_key_secret,
|
||||
gcp_credentials_json_secret=gcp_credentials_json_secret,
|
||||
huggingface_token_secret=huggingface_token_secret,
|
||||
exist_ok=exist_ok,
|
||||
|
||||
@@ -50,6 +50,7 @@ class StorageIntegrationInfo:
|
||||
azure_client_secret_secret: Optional[SecretReference] = None
|
||||
gcp_credentials_json_secret: Optional[SecretReference] = None
|
||||
huggingface_token_secret: Optional[SecretReference] = None
|
||||
azure_storage_account_access_key_secret: Optional[SecretReference] = None
|
||||
|
||||
def __post_init__(self):
|
||||
for field in (
|
||||
@@ -58,6 +59,7 @@ class StorageIntegrationInfo:
|
||||
"azure_tenant_id_secret",
|
||||
"azure_client_id_secret",
|
||||
"azure_client_secret_secret",
|
||||
"azure_storage_account_access_key_secret",
|
||||
"gcp_credentials_json_secret",
|
||||
"huggingface_token_secret",
|
||||
):
|
||||
|
||||
@@ -8,7 +8,7 @@ import pyarrow as pa
|
||||
import pytest
|
||||
|
||||
import lancedb
|
||||
from lancedb.functions import function
|
||||
from lancedb.functions import BlobWriter, function
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -61,3 +61,73 @@ async def test_function_exist_ok_forwards_sql_and_keeps_stored_version(entry, ex
|
||||
assert f'{prefix} "{stored["name"]}" FROM '.encode() in request
|
||||
assert b'"exist_ok"' not in request
|
||||
assert json.loads(version.to_canonical_json()) == stored
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_blob_writer_paths_round_trip_through_function_registration():
|
||||
flight = pytest.importorskip("pyarrow.flight")
|
||||
fixture = (
|
||||
Path(__file__).parents[3]
|
||||
/ "rust/lancedb/tests/fixtures/first_class_functions/v1"
|
||||
/ "remote_function_version.canonical.json"
|
||||
)
|
||||
stored = json.loads(fixture.read_text())
|
||||
expected_paths = [[{"field": "item"}], [{"field": "variants"}, "item"]]
|
||||
output_schema = pa.schema(
|
||||
[
|
||||
BlobWriter.field("item"),
|
||||
pa.field("variants", pa.list_(BlobWriter.field("asset"))),
|
||||
pa.field("checksum", pa.binary(), nullable=False),
|
||||
]
|
||||
)
|
||||
|
||||
@function(name=stored["name"], output_schema=output_schema)
|
||||
def render(text: str):
|
||||
with BlobWriter.open() as output:
|
||||
output.write(text.encode())
|
||||
return {"item": output, "variants": [b"", None], "checksum": b""}
|
||||
|
||||
expected_output = json.loads(
|
||||
render.registration_request.signature.output.to_canonical_json()
|
||||
)
|
||||
assert expected_output["kind"] == "named_struct_blob_writer"
|
||||
assert expected_output["blob_writer_paths"] == expected_paths
|
||||
stored["signature"] = {
|
||||
"inputs": [{"name": "text", "arrow_type": "utf8", "nullable": False}],
|
||||
"output": expected_output,
|
||||
}
|
||||
|
||||
class FunctionServer(flight.FlightServerBase):
|
||||
def __init__(self):
|
||||
super().__init__("grpc://127.0.0.1:0")
|
||||
self.requests = []
|
||||
|
||||
def do_get(self, context, ticket):
|
||||
self.requests.append(ticket.ticket)
|
||||
return flight.RecordBatchStream(
|
||||
pa.table({"definition": [json.dumps(stored)]})
|
||||
)
|
||||
|
||||
with FunctionServer() as server:
|
||||
db = await lancedb.connect_async(
|
||||
"db://analytics",
|
||||
api_key="test-key",
|
||||
host_override="http://localhost:10024",
|
||||
sql_host_override=f"grpc://127.0.0.1:{server.port}",
|
||||
)
|
||||
job = await db.create_function_async(render)
|
||||
version = await job.wait()
|
||||
(request,) = server.requests
|
||||
|
||||
assert b"CREATE FUNCTION" in request
|
||||
_, marker, body = request.partition(b" FROM '{")
|
||||
assert marker
|
||||
submitted, _ = json.JSONDecoder().raw_decode("{" + body.decode(errors="replace"))
|
||||
assert submitted["signature"]["output"] == expected_output
|
||||
assert (
|
||||
json.loads(version.to_canonical_json())["signature"]["output"]
|
||||
== expected_output
|
||||
)
|
||||
application = version(text=lancedb.col("text")).rename(columns={"item": "payload"})
|
||||
assert json.loads(application.to_canonical_json())["output"] == expected_output
|
||||
assert application.columns == {"item": "payload"}
|
||||
|
||||
@@ -23,8 +23,14 @@ import pyarrow as pa
|
||||
import pyarrow.compute as pc
|
||||
import pytest
|
||||
|
||||
from lancedb import col
|
||||
from lancedb.functions import FunctionDefinition, FunctionVersion, function, udf
|
||||
from lancedb import blob, col
|
||||
from lancedb.functions import (
|
||||
BlobWriter,
|
||||
FunctionDefinition,
|
||||
FunctionVersion,
|
||||
function,
|
||||
udf,
|
||||
)
|
||||
|
||||
FIXTURES = (
|
||||
Path(__file__).parents[3]
|
||||
@@ -625,6 +631,203 @@ def test_class_definition_binds_initialization_only_on_a_version():
|
||||
scale(factor=col("factor"), label="x")
|
||||
|
||||
|
||||
def test_blob_writer_scalar_annotation_and_bytes_keep_distinct_wire_shapes():
|
||||
@function
|
||||
def render(text: str) -> BlobWriter:
|
||||
with BlobWriter.open() as output:
|
||||
output.write(text.encode())
|
||||
return output
|
||||
|
||||
@function(output_schema=blob("image", nullable=False))
|
||||
def render_bytes(text: str) -> bytes:
|
||||
return text.encode()
|
||||
|
||||
scalar = {"kind": "scalar", "arrow_type": "blob_v2", "nullable": False}
|
||||
writer = {**scalar, "kind": "scalar_blob_writer", "blob_writer_paths": [[]]}
|
||||
for definition, expected in ((render, writer), (render_bytes, scalar)):
|
||||
request = json.loads(definition.registration_request.to_canonical_json())
|
||||
assert request["signature"]["output"] == expected
|
||||
assert request["artifact"]["adapter"] == {
|
||||
"kind": "scalar_to_arrow_batch",
|
||||
"version": 1,
|
||||
}
|
||||
assert render_bytes("text") == b"text"
|
||||
with pytest.raises(RuntimeError, match="computed column refresh"):
|
||||
render("text")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("input_type", ["Array", "RecordBatch"])
|
||||
@pytest.mark.parametrize("return_type", ["list[Writer]", "tuple[Writer, ...]"])
|
||||
def test_blob_writer_vectorized_annotations_resolve_in_the_artifact(
|
||||
helper_package, monkeypatch, input_type, return_type
|
||||
):
|
||||
as_tuple = return_type.startswith("tuple")
|
||||
result = "tuple(results)" if as_tuple else "results"
|
||||
column = "values" if input_type == "Array" else "values.column(0)"
|
||||
module = helper_package(
|
||||
"fx_blob_writers",
|
||||
{
|
||||
"__init__.py": f"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pyarrow as pa
|
||||
from pyarrow import {input_type} as Batch
|
||||
from lancedb.functions import BlobWriter as Writer, function
|
||||
|
||||
Output = {return_type}
|
||||
|
||||
@function(input_schema=pa.schema([pa.field("values", pa.string())]))
|
||||
def render(values: Batch) -> Output:
|
||||
results = []
|
||||
for text in {column}:
|
||||
with Writer.open() as output:
|
||||
output.write(text.as_py().encode())
|
||||
results.append(output)
|
||||
return {result}
|
||||
""",
|
||||
},
|
||||
)
|
||||
assert json.loads(
|
||||
module.render.registration_request.signature.output.to_canonical_json()
|
||||
) == {
|
||||
"kind": "scalar_blob_writer",
|
||||
"arrow_type": "blob_v2",
|
||||
"nullable": False,
|
||||
"blob_writer_paths": [[]],
|
||||
}
|
||||
|
||||
class WorkerWriter:
|
||||
def __init__(self):
|
||||
self.payload = bytearray()
|
||||
self.closed = False
|
||||
|
||||
@classmethod
|
||||
def open(cls):
|
||||
return cls()
|
||||
|
||||
def write(self, data):
|
||||
self.payload.extend(data)
|
||||
return len(data)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *_):
|
||||
self.closed = True
|
||||
|
||||
worker = types.ModuleType("lance_blob")
|
||||
worker.BlobWriter = WorkerWriter
|
||||
monkeypatch.setitem(sys.modules, "lance_blob", worker)
|
||||
namespace = {}
|
||||
exec(compile(artifact(module.render), "user_function.py", "exec"), namespace)
|
||||
render = namespace["render"]
|
||||
input_annotation = getattr(pa, input_type)
|
||||
output_annotation = (
|
||||
tuple[WorkerWriter, ...]
|
||||
if return_type.startswith("tuple")
|
||||
else list[WorkerWriter]
|
||||
)
|
||||
assert get_type_hints(render) == {
|
||||
"values": input_annotation,
|
||||
"return": output_annotation,
|
||||
}
|
||||
column = pa.array(["alpha", "", "omega"])
|
||||
batch = column if input_type == "Array" else pa.record_batch([column], names=["x"])
|
||||
output = render(batch)
|
||||
assert [(type(value), value.closed, bytes(value.payload)) for value in output] == [
|
||||
(WorkerWriter, True, b"alpha"),
|
||||
(WorkerWriter, True, b""),
|
||||
(WorkerWriter, True, b"omega"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("list_type", [pa.list_, pa.large_list])
|
||||
def test_blob_writer_nested_paths_keep_logical_arrow_schema(list_type):
|
||||
def output_schema(blob_field):
|
||||
return list_type(
|
||||
pa.field(
|
||||
"asset",
|
||||
pa.struct(
|
||||
[
|
||||
blob_field("item"),
|
||||
blob("bytes_sibling"),
|
||||
pa.field("checksum", pa.binary(), nullable=False),
|
||||
blob_field("rendered.blob", nullable=False),
|
||||
]
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
def render_batch(values: pa.Array):
|
||||
return [
|
||||
[
|
||||
{
|
||||
"item": None,
|
||||
"bytes_sibling": b"",
|
||||
"checksum": b"ok",
|
||||
"rendered.blob": b"",
|
||||
}
|
||||
]
|
||||
] * len(values)
|
||||
|
||||
input_schema = pa.schema([pa.field("values", pa.string())])
|
||||
streaming = function(
|
||||
render_batch,
|
||||
input_schema=input_schema,
|
||||
output_schema=output_schema(BlobWriter.field),
|
||||
)
|
||||
materialized = function(
|
||||
render_batch, input_schema=input_schema, output_schema=output_schema(blob)
|
||||
)
|
||||
plain = json.loads(
|
||||
materialized.registration_request.signature.output.to_canonical_json()
|
||||
)
|
||||
writer = json.loads(
|
||||
streaming.registration_request.signature.output.to_canonical_json()
|
||||
)
|
||||
assert writer == {
|
||||
**plain,
|
||||
"kind": "scalar_blob_writer",
|
||||
"blob_writer_paths": [
|
||||
["item", {"field": "item"}],
|
||||
["item", {"field": "rendered.blob"}],
|
||||
],
|
||||
}
|
||||
item = json.loads(writer["arrow_type"])["fields"][0]
|
||||
assert item["name"] == "asset"
|
||||
assert item["nullable"] is True
|
||||
assert item["type"]["fields"][0]["metadata"] == {
|
||||
"ARROW:extension:name": "lance.blob.v2"
|
||||
}
|
||||
|
||||
|
||||
def test_blob_writer_requires_supported_output_leaves():
|
||||
def annotated(value: str) -> BlobWriter:
|
||||
return BlobWriter.open()
|
||||
|
||||
def optional(value: str) -> BlobWriter | None:
|
||||
return None
|
||||
|
||||
def explicit(value: str):
|
||||
return value
|
||||
|
||||
with pytest.raises(TypeError, match="requires a Blob v2 field"):
|
||||
function(annotated, output_schema=pa.binary())
|
||||
with pytest.raises(ValueError, match="must be non-nullable"):
|
||||
function(optional)
|
||||
invalid_field = pa.field(
|
||||
"value", pa.binary(), metadata={"lance.function.blob_writer": "true"}
|
||||
)
|
||||
with pytest.raises(TypeError, match="requires a Blob v2 field"):
|
||||
function(explicit, output_schema=pa.struct([invalid_field]))
|
||||
for schema in (
|
||||
pa.list_(BlobWriter.field("item"), 2),
|
||||
pa.map_(pa.string(), BlobWriter.field("value")),
|
||||
):
|
||||
with pytest.raises(TypeError, match="nested under collection types"):
|
||||
function(explicit, output_schema=schema)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("class_function", [False, True])
|
||||
@pytest.mark.parametrize("postponed", [False, True])
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -1374,7 +1374,11 @@ async def test_profile_wait_preserves_timeout_and_never_waits_or_cancels_parent(
|
||||
await asyncio.to_thread(Job(job).wait_for_profile, "profile-1", **kwargs)
|
||||
else:
|
||||
await job.wait_for_profile("profile-1", **kwargs)
|
||||
assert caught.value is error
|
||||
assert caught.value.args == error.args
|
||||
# On Python 3.11 and 3.12, run_coroutine_threadsafe re-creates TimeoutError
|
||||
# when copying it across futures, so identity only holds on the async path.
|
||||
if not sync:
|
||||
assert caught.value is error
|
||||
inner.wait_for_profile.assert_awaited_once_with(
|
||||
"profile-1", timeout_seconds=0.05, poll_interval_seconds=5.0
|
||||
)
|
||||
|
||||
@@ -68,8 +68,17 @@ def test_windows_wheel_tag_and_native_import():
|
||||
if not wheels:
|
||||
pytest.skip("no wheel artifact is available in this development environment")
|
||||
|
||||
# The wheel is tagged with the abi3 floor, which follows requires-python.
|
||||
minimum_python = re.search(
|
||||
r'^requires-python\s*=\s*">=(\d+)\.(\d+)"$',
|
||||
(project_dir / "pyproject.toml").read_text(),
|
||||
re.MULTILINE,
|
||||
)
|
||||
assert minimum_python is not None
|
||||
major, minor = minimum_python.groups()
|
||||
|
||||
assert len(wheels) == 1
|
||||
assert wheels[0].name.endswith("-cp310-abi3-win_amd64.whl")
|
||||
assert wheels[0].name.endswith(f"-cp{major}{minor}-abi3-win_amd64.whl")
|
||||
|
||||
native_module = importlib.import_module("lancedb._lancedb")
|
||||
assert Path(native_module.__file__).suffix == ".pyd"
|
||||
|
||||
@@ -118,14 +118,23 @@ def remote_server(text_type=pa.string()):
|
||||
trust_policy=None,
|
||||
permissions_policy=None,
|
||||
)
|
||||
for field, name in (
|
||||
("azure_tenant_id_secret", "tenant"),
|
||||
("azure_client_id_secret", "client"),
|
||||
("azure_client_secret_secret", "credential"),
|
||||
):
|
||||
info[field] = dict(
|
||||
database="shared", namespace_path=["credentials"], name=name
|
||||
if b"STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET" in command:
|
||||
info["azure_storage_account_access_key_secret"] = dict(
|
||||
database="shared",
|
||||
namespace_path=["credentials"],
|
||||
name="blob_key",
|
||||
)
|
||||
else:
|
||||
for field, name in (
|
||||
("azure_tenant_id_secret", "tenant"),
|
||||
("azure_client_id_secret", "client"),
|
||||
("azure_client_secret_secret", "credential"),
|
||||
):
|
||||
info[field] = dict(
|
||||
database="shared",
|
||||
namespace_path=["credentials"],
|
||||
name=name,
|
||||
)
|
||||
if b"STORAGE_AWS_ACCESS_KEY_ID_SECRET" in command:
|
||||
info["aws_role_arn"] = None
|
||||
info["trust_policy"] = None
|
||||
@@ -149,6 +158,7 @@ def remote_server(text_type=pa.string()):
|
||||
"azure_tenant_id_secret",
|
||||
"azure_client_id_secret",
|
||||
"azure_client_secret_secret",
|
||||
"azure_storage_account_access_key_secret",
|
||||
"gcp_credentials_json_secret",
|
||||
"huggingface_token_secret",
|
||||
]:
|
||||
@@ -339,6 +349,44 @@ def test_azure_lifecycle_uses_three_qualified_secret_references(text_type):
|
||||
assert b"STORAGE_AWS" not in sql
|
||||
|
||||
|
||||
def test_azure_lifecycle_uses_one_qualified_account_access_key_secret():
|
||||
with remote_server() as (host, calls):
|
||||
db = connect(host)
|
||||
key = SecretReference(
|
||||
"blob_key", database="shared", namespace_path=("credentials",)
|
||||
)
|
||||
config = {
|
||||
"storage_provider": "AZURE",
|
||||
"azure_storage_account": "customeraccount",
|
||||
"azure_storage_account_access_key_secret": key,
|
||||
}
|
||||
with pytest.raises(ValueError, match="service principal"):
|
||||
db.create_storage_integration(
|
||||
"blobs",
|
||||
"az://customer-data/raw/",
|
||||
azure_client_id_secret="client",
|
||||
**config,
|
||||
)
|
||||
assert calls == []
|
||||
|
||||
info = db.create_storage_integration(
|
||||
"blobs", "az://customer-data/raw/", **config
|
||||
)
|
||||
reference = info.azure_storage_account_access_key_secret
|
||||
assert reference is not None
|
||||
assert reference.name == key.name
|
||||
assert reference.database == key.database
|
||||
assert tuple(reference.namespace_path) == key.namespace_path
|
||||
assert info.azure_tenant_id_secret is None
|
||||
assert info.azure_client_id_secret is None
|
||||
assert info.azure_client_secret_secret is None
|
||||
assert db.describe_storage_integration("blobs") == info
|
||||
assert (
|
||||
b"STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET = "
|
||||
b'"shared"."credentials"."blob_key"' in calls[0]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_azure_requires_account_and_all_three_secret_references():
|
||||
with remote_server() as (host, calls):
|
||||
|
||||
Generated
+52
-1147
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lancedb"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
edition.workspace = true
|
||||
description = "LanceDB: A serverless, low-latency vector database for AI applications"
|
||||
license.workspace = true
|
||||
@@ -46,7 +46,7 @@ lance-io = { workspace = true }
|
||||
lance-index = { workspace = true, features = ["tokenizer-jieba", "tokenizer-lindera"] }
|
||||
lance-table = { workspace = true }
|
||||
# Keep the upstream source for downstream SDKs, where workspace patches do not apply.
|
||||
lance-linalg = { "version" = "=15.0.0-beta.28", "tag" = "v15.0.0-beta.28", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-linalg = { "version" = "=15.0.0-beta.29", "tag" = "v15.0.0-beta.29", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { workspace = true }
|
||||
lance-arrow = { workspace = true }
|
||||
lance-namespace = { workspace = true }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lancedb-cli"
|
||||
version = "0.42.0-beta.25"
|
||||
version = "0.42.0-beta.27"
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
@@ -162,15 +162,23 @@ fn application_has_unknown_nested_fields(value: &Value) -> bool {
|
||||
return true;
|
||||
}
|
||||
application.get("output").is_some_and(|output| {
|
||||
has_unknown_keys(output, &["kind", "arrow_type", "nullable", "fields"])
|
||||
|| output
|
||||
.get("fields")
|
||||
.and_then(Value::as_array)
|
||||
.is_some_and(|fields| {
|
||||
fields
|
||||
.iter()
|
||||
.any(|field| has_unknown_keys(field, &["name", "arrow_type", "nullable"]))
|
||||
})
|
||||
has_unknown_keys(
|
||||
output,
|
||||
&[
|
||||
"kind",
|
||||
"arrow_type",
|
||||
"nullable",
|
||||
"fields",
|
||||
"blob_writer_paths",
|
||||
],
|
||||
) || output
|
||||
.get("fields")
|
||||
.and_then(Value::as_array)
|
||||
.is_some_and(|fields| {
|
||||
fields
|
||||
.iter()
|
||||
.any(|field| has_unknown_keys(field, &["name", "arrow_type", "nullable"]))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -224,6 +232,23 @@ pub struct FunctionResultField {
|
||||
pub nullable: bool,
|
||||
}
|
||||
|
||||
/// One step from the Function result root to a writer-capable Blob v2 leaf.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(untagged, deny_unknown_fields)]
|
||||
pub enum BlobWriterPathStep {
|
||||
/// A struct child addressed by its literal Arrow field name.
|
||||
Field { field: String },
|
||||
/// A list value field, independent of its name.
|
||||
ListItem(BlobWriterListItem),
|
||||
}
|
||||
|
||||
/// The list step in a Blob writer path, encoded as `"item"`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum BlobWriterListItem {
|
||||
Item,
|
||||
}
|
||||
|
||||
/// Scalar or named-struct Function output.
|
||||
///
|
||||
/// `kind` remains a string so unknown future result shapes can be decoded.
|
||||
@@ -236,6 +261,11 @@ pub struct FunctionOutput {
|
||||
pub nullable: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub fields: Vec<FunctionResultField>,
|
||||
/// Writer-capable Blob v2 leaves in `scalar_blob_writer` and
|
||||
/// `named_struct_blob_writer` results. An empty path denotes a scalar
|
||||
/// Blob result; an empty list denotes a result with no writer leaves.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub blob_writer_paths: Vec<Vec<BlobWriterPathStep>>,
|
||||
}
|
||||
|
||||
/// Ordered language-neutral Function signature.
|
||||
|
||||
@@ -75,6 +75,7 @@ pub(super) fn create_sql(
|
||||
|| request.azure_tenant_id_secret.is_some()
|
||||
|| request.azure_client_id_secret.is_some()
|
||||
|| request.azure_client_secret_secret.is_some()
|
||||
|| request.azure_storage_account_access_key_secret.is_some()
|
||||
|| request.gcp_credentials_json_secret.is_some()
|
||||
{
|
||||
return Err(invalid(
|
||||
@@ -110,6 +111,7 @@ pub(super) fn create_sql(
|
||||
|| request.azure_tenant_id_secret.is_some()
|
||||
|| request.azure_client_id_secret.is_some()
|
||||
|| request.azure_client_secret_secret.is_some()
|
||||
|| request.azure_storage_account_access_key_secret.is_some()
|
||||
{
|
||||
return Err(invalid(
|
||||
"GCP integrations cannot contain AWS or Azure options",
|
||||
@@ -145,24 +147,32 @@ pub(super) fn create_sql(
|
||||
literal(&request.storage_prefix),
|
||||
literal(account)
|
||||
);
|
||||
for (key, reference) in [
|
||||
(
|
||||
"STORAGE_AZURE_TENANT_ID_SECRET",
|
||||
&request.azure_tenant_id_secret,
|
||||
),
|
||||
(
|
||||
"STORAGE_AZURE_CLIENT_ID_SECRET",
|
||||
&request.azure_client_id_secret,
|
||||
),
|
||||
(
|
||||
"STORAGE_AZURE_CLIENT_SECRET_SECRET",
|
||||
&request.azure_client_secret_secret,
|
||||
),
|
||||
] {
|
||||
let reference = reference.as_ref().ok_or_else(|| {
|
||||
invalid("Azure integrations require all three credential Secret references")
|
||||
})?;
|
||||
sql.push_str(&format!(" {key} = {}", secret_name(reference)?));
|
||||
match (
|
||||
&request.azure_storage_account_access_key_secret,
|
||||
&request.azure_tenant_id_secret,
|
||||
&request.azure_client_id_secret,
|
||||
&request.azure_client_secret_secret,
|
||||
) {
|
||||
(Some(reference), None, None, None) => {
|
||||
sql.push_str(&format!(
|
||||
" STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET = {}",
|
||||
secret_name(reference)?
|
||||
));
|
||||
}
|
||||
(None, Some(tenant), Some(client), Some(secret)) => {
|
||||
for (key, reference) in [
|
||||
("STORAGE_AZURE_TENANT_ID_SECRET", tenant),
|
||||
("STORAGE_AZURE_CLIENT_ID_SECRET", client),
|
||||
("STORAGE_AZURE_CLIENT_SECRET_SECRET", secret),
|
||||
] {
|
||||
sql.push_str(&format!(" {key} = {}", secret_name(reference)?));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
return Err(invalid(
|
||||
"Specify either azure_storage_account_access_key_secret or all three Azure service principal Secret references",
|
||||
));
|
||||
}
|
||||
}
|
||||
return Ok(sql);
|
||||
}
|
||||
@@ -170,6 +180,7 @@ pub(super) fn create_sql(
|
||||
|| request.azure_tenant_id_secret.is_some()
|
||||
|| request.azure_client_id_secret.is_some()
|
||||
|| request.azure_client_secret_secret.is_some()
|
||||
|| request.azure_storage_account_access_key_secret.is_some()
|
||||
{
|
||||
return Err(invalid("S3 integrations cannot contain Azure options"));
|
||||
}
|
||||
@@ -244,6 +255,7 @@ pub(super) fn decode_info(batches: &[RecordBatch]) -> Result<StorageIntegrationI
|
||||
| "azure_tenant_id_secret"
|
||||
| "azure_client_id_secret"
|
||||
| "azure_client_secret_secret"
|
||||
| "azure_storage_account_access_key_secret"
|
||||
| "gcp_credentials_json_secret"
|
||||
| "huggingface_token_secret"
|
||||
| "trust_policy"
|
||||
@@ -265,6 +277,28 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn azure_account_access_key_sql_references_only_the_key_secret() {
|
||||
let mut request = CreateStorageIntegrationRequest::azure_with_account_access_key(
|
||||
"az://customer-data/raw/",
|
||||
"customeraccount",
|
||||
SecretReference::new("blob_key")
|
||||
.with_database("shared")
|
||||
.with_namespace(vec!["credentials".into()]),
|
||||
);
|
||||
let sql = create_sql("blobs", &[], &request).unwrap();
|
||||
assert!(sql.contains("STORAGE_AZURE_STORAGE_ACCOUNT = 'customeraccount'"));
|
||||
assert!(sql.contains(
|
||||
r#"STORAGE_AZURE_STORAGE_ACCOUNT_ACCESS_KEY_SECRET = "shared"."credentials"."blob_key""#
|
||||
));
|
||||
assert!(!sql.contains("STORAGE_AZURE_TENANT_ID_SECRET"));
|
||||
assert!(!sql.contains("STORAGE_AZURE_CLIENT_ID_SECRET"));
|
||||
assert!(!sql.contains("STORAGE_AZURE_CLIENT_SECRET_SECRET"));
|
||||
|
||||
request.azure_client_id_secret = Some(SecretReference::new("client"));
|
||||
assert!(create_sql("blobs", &[], &request).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_if_not_exists_preserves_provider_options() {
|
||||
let secret = SecretReference::new("credential");
|
||||
|
||||
@@ -62,6 +62,8 @@ pub struct CreateStorageIntegrationRequest {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub azure_client_secret_secret: Option<SecretReference>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub azure_storage_account_access_key_secret: Option<SecretReference>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub gcp_credentials_json_secret: Option<SecretReference>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub huggingface_token_secret: Option<SecretReference>,
|
||||
@@ -113,6 +115,7 @@ impl CreateStorageIntegrationRequest {
|
||||
azure_tenant_id_secret: None,
|
||||
azure_client_id_secret: None,
|
||||
azure_client_secret_secret: None,
|
||||
azure_storage_account_access_key_secret: None,
|
||||
gcp_credentials_json_secret: None,
|
||||
huggingface_token_secret: None,
|
||||
}
|
||||
@@ -136,6 +139,7 @@ impl CreateStorageIntegrationRequest {
|
||||
azure_tenant_id_secret: None,
|
||||
azure_client_id_secret: None,
|
||||
azure_client_secret_secret: None,
|
||||
azure_storage_account_access_key_secret: None,
|
||||
gcp_credentials_json_secret: None,
|
||||
huggingface_token_secret: None,
|
||||
}
|
||||
@@ -166,6 +170,38 @@ impl CreateStorageIntegrationRequest {
|
||||
azure_tenant_id_secret: Some(tenant_id),
|
||||
azure_client_id_secret: Some(client_id),
|
||||
azure_client_secret_secret: Some(client_secret),
|
||||
azure_storage_account_access_key_secret: None,
|
||||
gcp_credentials_json_secret: None,
|
||||
huggingface_token_secret: None,
|
||||
aws_role_arn: None,
|
||||
aws_access_key_id_secret: None,
|
||||
aws_secret_access_key_secret: None,
|
||||
aws_region: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Register Azure Blob access using a Secret containing a storage account access key.
|
||||
///
|
||||
/// ```
|
||||
/// use lancedb::storage_integration::{CreateStorageIntegrationRequest, SecretReference};
|
||||
/// let config = CreateStorageIntegrationRequest::azure_with_account_access_key(
|
||||
/// "az://customer-data/raw/", "customeraccount", SecretReference::new("azure_key"),
|
||||
/// );
|
||||
/// ```
|
||||
pub fn azure_with_account_access_key(
|
||||
storage_prefix: impl Into<String>,
|
||||
storage_account: impl Into<String>,
|
||||
access_key: SecretReference,
|
||||
) -> Self {
|
||||
Self {
|
||||
storage_provider: StorageProvider::Azure,
|
||||
storage_prefix: storage_prefix.into(),
|
||||
exist_ok: false,
|
||||
azure_storage_account: Some(storage_account.into()),
|
||||
azure_storage_account_access_key_secret: Some(access_key),
|
||||
azure_tenant_id_secret: None,
|
||||
azure_client_id_secret: None,
|
||||
azure_client_secret_secret: None,
|
||||
gcp_credentials_json_secret: None,
|
||||
huggingface_token_secret: None,
|
||||
aws_role_arn: None,
|
||||
@@ -198,6 +234,7 @@ impl CreateStorageIntegrationRequest {
|
||||
azure_tenant_id_secret: None,
|
||||
azure_client_id_secret: None,
|
||||
azure_client_secret_secret: None,
|
||||
azure_storage_account_access_key_secret: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +262,7 @@ impl CreateStorageIntegrationRequest {
|
||||
azure_tenant_id_secret: None,
|
||||
azure_client_id_secret: None,
|
||||
azure_client_secret_secret: None,
|
||||
azure_storage_account_access_key_secret: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +308,8 @@ pub struct StorageIntegrationInfo {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub azure_client_secret_secret: Option<SecretReference>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub azure_storage_account_access_key_secret: Option<SecretReference>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub gcp_credentials_json_secret: Option<SecretReference>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub huggingface_token_secret: Option<SecretReference>,
|
||||
|
||||
@@ -1709,7 +1709,7 @@ pub(crate) fn plan_function_application(
|
||||
let mut outputs = Vec::new();
|
||||
let mut output_fields = Vec::new();
|
||||
match output.kind.as_str() {
|
||||
"scalar" => {
|
||||
"scalar" | "scalar_blob_writer" => {
|
||||
if !application.columns().is_empty() {
|
||||
return Err(invalid_function(
|
||||
"scalar Function applications cannot rename result fields",
|
||||
@@ -1738,7 +1738,7 @@ pub(crate) fn plan_function_application(
|
||||
});
|
||||
output_fields.push(function_output_field(name, true, arrow_type)?);
|
||||
}
|
||||
"named_struct" => {
|
||||
"named_struct" | "named_struct_blob_writer" => {
|
||||
if output.fields.is_empty() {
|
||||
return Err(invalid_function(
|
||||
"named-struct Function output requires at least one field",
|
||||
@@ -5197,17 +5197,53 @@ mod tests {
|
||||
#[test]
|
||||
fn test_blob_function_plans_semantic_input_and_scalar_output() {
|
||||
let schema = ArrowSchema::new(vec![crate::blob("image", false)]);
|
||||
let application =
|
||||
blob_application(r#"{"kind":"scalar","arrow_type":"blob_v2","nullable":false}"#);
|
||||
let plan = plan_function_application(&schema, &application, Some("thumbnail")).unwrap();
|
||||
for output in [
|
||||
r#"{"kind":"scalar","arrow_type":"blob_v2","nullable":false}"#,
|
||||
r#"{"kind":"scalar_blob_writer","arrow_type":"blob_v2","nullable":false,"blob_writer_paths":[[]]}"#,
|
||||
] {
|
||||
let application = blob_application(output);
|
||||
let plan = plan_function_application(&schema, &application, Some("thumbnail")).unwrap();
|
||||
|
||||
assert_eq!(plan.input_bindings[0].arrow_type, FUNCTION_BLOB_V2_TYPE);
|
||||
let input_schema =
|
||||
lance_namespace::schema::convert_json_arrow_schema(&plan.input_schema).unwrap();
|
||||
assert!(input_schema.field(0).is_blob_v2());
|
||||
let output_schema =
|
||||
lance_namespace::schema::convert_json_arrow_schema(&plan.output_schema).unwrap();
|
||||
assert!(output_schema.field(0).is_blob_v2());
|
||||
assert_eq!(plan.input_bindings[0].arrow_type, FUNCTION_BLOB_V2_TYPE);
|
||||
let input_schema =
|
||||
lance_namespace::schema::convert_json_arrow_schema(&plan.input_schema).unwrap();
|
||||
assert!(input_schema.field(0).is_blob_v2());
|
||||
let output_schema =
|
||||
lance_namespace::schema::convert_json_arrow_schema(&plan.output_schema).unwrap();
|
||||
assert!(output_schema.field(0).is_blob_v2());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_named_blob_writer_plan_preserves_logical_output_columns() {
|
||||
let schema = ArrowSchema::new(vec![crate::blob("image", false)]);
|
||||
let application = blob_application(
|
||||
r#"{
|
||||
"kind":"named_struct_blob_writer",
|
||||
"fields":[
|
||||
{"name":"item","arrow_type":"blob_v2","nullable":true},
|
||||
{"name":"checksum","arrow_type":"binary","nullable":false}
|
||||
],
|
||||
"blob_writer_paths":[[{"field":"item"}]]
|
||||
}"#,
|
||||
);
|
||||
let expanded = plan_function_application(&schema, &application, None).unwrap();
|
||||
let expanded_schema =
|
||||
lance_namespace::schema::convert_json_arrow_schema(&expanded.output_schema).unwrap();
|
||||
assert_eq!(expanded_schema.field(0).name(), "item");
|
||||
assert!(expanded_schema.field(0).is_blob_v2());
|
||||
assert_eq!(expanded_schema.field(1).data_type(), &DataType::Binary);
|
||||
|
||||
let whole = plan_function_application(&schema, &application, Some("rendered")).unwrap();
|
||||
let whole_schema =
|
||||
lance_namespace::schema::convert_json_arrow_schema(&whole.output_schema).unwrap();
|
||||
let DataType::Struct(fields) = whole_schema.field(0).data_type() else {
|
||||
panic!("named writer output must bind as a struct");
|
||||
};
|
||||
assert!(fields[0].is_blob_v2());
|
||||
assert!(fields[0].is_nullable());
|
||||
assert_eq!(fields[1].data_type(), &DataType::Binary);
|
||||
assert!(!fields[1].is_nullable());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1664,6 +1664,74 @@ mod tests {
|
||||
assert_eq!(null_count, 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_btree_index_on_large_utf8() {
|
||||
let conn = connect("memory://").execute().await.unwrap();
|
||||
let schema = Arc::new(Schema::new(vec![
|
||||
Field::new("explicit", DataType::LargeUtf8, true),
|
||||
Field::new("auto", DataType::LargeUtf8, true),
|
||||
]));
|
||||
let values = || {
|
||||
Arc::new(LargeStringArray::from(vec![
|
||||
Some("alpha"),
|
||||
None,
|
||||
Some("omega"),
|
||||
Some("alpha"),
|
||||
])) as ArrayRef
|
||||
};
|
||||
let batch = RecordBatch::try_new(schema, vec![values(), values()]).unwrap();
|
||||
let table = conn
|
||||
.create_table("large_utf8_btree_table", batch)
|
||||
.execute()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
table
|
||||
.create_index(&["explicit"], Index::BTree(BTreeIndexBuilder::default()))
|
||||
.execute()
|
||||
.await
|
||||
.unwrap();
|
||||
// Auto picks BTree for string columns, so LargeUtf8 must get one too.
|
||||
table
|
||||
.create_index(&["auto"], Index::Auto)
|
||||
.execute()
|
||||
.await
|
||||
.unwrap();
|
||||
table
|
||||
.wait_for_index(&["explicit_idx", "auto_idx"], Duration::from_millis(10))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let index_configs = table.list_indices().await.unwrap();
|
||||
assert_eq!(index_configs.len(), 2);
|
||||
for index in index_configs {
|
||||
assert_eq!(index.index_type, crate::index::IndexType::BTree);
|
||||
}
|
||||
|
||||
for column in ["explicit", "auto"] {
|
||||
for (filter, expected_rows) in [
|
||||
(format!("{column} = 'alpha'"), 2),
|
||||
(format!("{column} > 'beta'"), 1),
|
||||
(format!("{column} IS NULL"), 1),
|
||||
] {
|
||||
let query = table.query().only_if(filter.as_str());
|
||||
let plan = query.explain_plan(false).await.unwrap();
|
||||
assert!(plan.contains("ScalarIndexQuery"), "{filter}: {plan}");
|
||||
let num_rows = query
|
||||
.execute()
|
||||
.await
|
||||
.unwrap()
|
||||
.try_collect::<Vec<_>>()
|
||||
.await
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|b| b.num_rows())
|
||||
.sum::<usize>();
|
||||
assert_eq!(num_rows, expected_rows, "{filter}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_builtin_scalar_index() {
|
||||
for (index, index_type, predicate, invalid_column) in [
|
||||
|
||||
@@ -539,6 +539,7 @@ pub fn supported_btree_data_type(dtype: &DataType) -> bool {
|
||||
dtype,
|
||||
DataType::Boolean
|
||||
| DataType::Utf8
|
||||
| DataType::LargeUtf8
|
||||
| DataType::Time32(_)
|
||||
| DataType::Time64(_)
|
||||
| DataType::Date32
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lance-linalg"
|
||||
version = "15.0.0-beta.28"
|
||||
version = "15.0.0-beta.29"
|
||||
publish = false
|
||||
edition = { workspace = true }
|
||||
license = { workspace = true }
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
This directory contains `rust/lance-linalg` from Lance tag `v15.0.0-beta.28`
|
||||
(commit `4e5530c0ed83d3978e35d0e585257ddf438b9cf7`), licensed under Apache-2.0.
|
||||
This directory contains `rust/lance-linalg` from Lance tag `v15.0.0-beta.29`
|
||||
(commit `ded121cd9a99dc83040cf41049dc2bd3963241b9`), licensed under Apache-2.0.
|
||||
|
||||
LanceDB patches `src/distance/cosine.rs` to recompute FLOAT32 cosine distances
|
||||
in FLOAT64 when squared norms or dot products overflow or underflow. Ordinary
|
||||
|
||||
Reference in New Issue
Block a user