mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-28 13:33:59 +00:00
Merge main and align cosine patch with Lance 16.0.0-beta.5
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
[tool.bumpversion]
|
||||
current_version = "0.42.0-beta.37"
|
||||
current_version = "0.42.0-beta.38"
|
||||
parse = """(?x)
|
||||
(?P<major>0|[1-9]\\d*)\\.
|
||||
(?P<minor>0|[1-9]\\d*)\\.
|
||||
|
||||
Generated
+51
-51
@@ -3885,8 +3885,8 @@ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "fsst"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"rand 0.9.5",
|
||||
@@ -5364,8 +5364,8 @@ checksum = "e037a2e1d8d5fdbd49b16a4ea09d5d6401c1f29eca5ff29d03d3824dba16256a"
|
||||
|
||||
[[package]]
|
||||
name = "lance"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5441,8 +5441,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-arrow"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5465,8 +5465,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-bitpacking"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"crunchy",
|
||||
@@ -5476,8 +5476,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-core"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5515,8 +5515,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datafusion"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5547,8 +5547,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datafusion-exec"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5574,8 +5574,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-datagen"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5592,8 +5592,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-derive"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5602,8 +5602,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-encoding"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-arith",
|
||||
"arrow-array",
|
||||
@@ -5637,8 +5637,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-file"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-arith",
|
||||
"arrow-array",
|
||||
@@ -5668,8 +5668,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-geo"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5700,8 +5700,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-index"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5773,8 +5773,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-index-core"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -5797,8 +5797,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-io"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -5843,8 +5843,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-jsonb"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"ethnum",
|
||||
@@ -5861,7 +5861,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-linalg"
|
||||
version = "16.0.0-beta.4"
|
||||
version = "16.0.0-beta.5"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"argminmax 0.7.1",
|
||||
@@ -5883,8 +5883,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-namespace"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"async-trait",
|
||||
@@ -5898,8 +5898,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-namespace-impls"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
@@ -5953,8 +5953,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-select"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -5968,8 +5968,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-table"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
@@ -6010,8 +6010,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-table-runtime"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -6055,8 +6055,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-testing"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
@@ -6069,8 +6069,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lance-tokenizer"
|
||||
version = "16.0.0-beta.4"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.4#1686234925dde0289409fa31ff615d724943ccb6"
|
||||
version = "16.0.0-beta.5"
|
||||
source = "git+https://github.com/lance-format/lance.git?tag=v16.0.0-beta.5#0ea718506941b3e4c8dd0aee279a8ea1b7c7b076"
|
||||
dependencies = [
|
||||
"frostem",
|
||||
"icu_segmenter",
|
||||
@@ -6083,7 +6083,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb"
|
||||
version = "0.42.0-beta.37"
|
||||
version = "0.42.0-beta.38"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
@@ -6194,7 +6194,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb-cli"
|
||||
version = "0.42.0-beta.37"
|
||||
version = "0.42.0-beta.38"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrow-array",
|
||||
@@ -6237,7 +6237,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb-nodejs"
|
||||
version = "0.42.0-beta.37"
|
||||
version = "0.42.0-beta.38"
|
||||
dependencies = [
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
@@ -6263,7 +6263,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lancedb-python"
|
||||
version = "0.42.0-beta.37"
|
||||
version = "0.42.0-beta.38"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"arrow",
|
||||
|
||||
+14
-14
@@ -20,20 +20,20 @@ categories = ["database-implementations"]
|
||||
rust-version = "1.98.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
lance = { "version" = "=16.0.0-beta.4", default-features = false, "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-core = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datagen = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-file = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-io = { "version" = "=16.0.0-beta.4", default-features = false, "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-index = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-jsonb = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace-impls = { "version" = "=16.0.0-beta.4", default-features = false, "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-table = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-testing = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datafusion = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-arrow = { "version" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance = { "version" = "=16.0.0-beta.5", default-features = false, "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-core = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datagen = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-file = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-io = { "version" = "=16.0.0-beta.5", default-features = false, "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-index = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-jsonb = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-namespace-impls = { "version" = "=16.0.0-beta.5", default-features = false, "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-table = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-testing = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-datafusion = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-encoding = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-arrow = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lancedb = { path = "rust/lancedb", default-features = false }
|
||||
ahash = "0.8"
|
||||
anyhow = "1"
|
||||
|
||||
@@ -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.37</version>
|
||||
<version>0.42.0-beta.38</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
@@ -341,16 +341,24 @@ You can also use this method to create new "dynamic" columns based on your exist
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
To create dynamic columns you can pass in a Map<string, string | Expr>. A column will be
|
||||
returned for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string or an `Expr` that specifies how the column is calculated. An `Expr` built
|
||||
with `col` keeps the exact, case-sensitive column name.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
input to this method would be `new Map([["combined", "a + b"], ["c", "c"]])`.
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string | Expr>` (e.g. an object literal). This
|
||||
method uses `Object.entries` which should preserve the insertion order of the object.
|
||||
However, object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string`> \| `Record`<`string`, `string`>
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string` \| [`Expr`](Expr.md)> \| `Record`<`string`, `string` \| [`Expr`](Expr.md)>
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -359,14 +367,8 @@ input to this method would be:
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
table.query().select(new Map([["combined", "a + b"], ["c", "c"]]));
|
||||
table.query().select({ id: "id", doubled: col("unitPrice").mul(2) });
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
@@ -415,16 +415,24 @@ You can also use this method to create new "dynamic" columns based on your exist
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
To create dynamic columns you can pass in a Map<string, string | Expr>. A column will be
|
||||
returned for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string or an `Expr` that specifies how the column is calculated. An `Expr` built
|
||||
with `col` keeps the exact, case-sensitive column name.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
input to this method would be `new Map([["combined", "a + b"], ["c", "c"]])`.
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string | Expr>` (e.g. an object literal). This
|
||||
method uses `Object.entries` which should preserve the insertion order of the object.
|
||||
However, object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string`> \| `Record`<`string`, `string`>
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string` \| [`Expr`](Expr.md)> \| `Record`<`string`, `string` \| [`Expr`](Expr.md)>
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -433,14 +441,8 @@ input to this method would be:
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
table.query().select(new Map([["combined", "a + b"], ["c", "c"]]));
|
||||
table.query().select({ id: "id", doubled: col("unitPrice").mul(2) });
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
@@ -184,16 +184,24 @@ You can also use this method to create new "dynamic" columns based on your exist
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
To create dynamic columns you can pass in a Map<string, string | Expr>. A column will be
|
||||
returned for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string or an `Expr` that specifies how the column is calculated. An `Expr` built
|
||||
with `col` keeps the exact, case-sensitive column name.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
input to this method would be `new Map([["combined", "a + b"], ["c", "c"]])`.
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string | Expr>` (e.g. an object literal). This
|
||||
method uses `Object.entries` which should preserve the insertion order of the object.
|
||||
However, object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string`> \| `Record`<`string`, `string`>
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string` \| [`Expr`](Expr.md)> \| `Record`<`string`, `string` \| [`Expr`](Expr.md)>
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -202,14 +210,8 @@ input to this method would be:
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
table.query().select(new Map([["combined", "a + b"], ["c", "c"]]));
|
||||
table.query().select({ id: "id", doubled: col("unitPrice").mul(2) });
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
@@ -191,16 +191,24 @@ You can also use this method to create new "dynamic" columns based on your exist
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
To create dynamic columns you can pass in a Map<string, string | Expr>. A column will be
|
||||
returned for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string or an `Expr` that specifies how the column is calculated. An `Expr` built
|
||||
with `col` keeps the exact, case-sensitive column name.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
input to this method would be `new Map([["combined", "a + b"], ["c", "c"]])`.
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string | Expr>` (e.g. an object literal). This
|
||||
method uses `Object.entries` which should preserve the insertion order of the object.
|
||||
However, object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string`> \| `Record`<`string`, `string`>
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string` \| [`Expr`](Expr.md)> \| `Record`<`string`, `string` \| [`Expr`](Expr.md)>
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -209,14 +217,8 @@ input to this method would be:
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
table.query().select(new Map([["combined", "a + b"], ["c", "c"]]));
|
||||
table.query().select({ id: "id", doubled: col("unitPrice").mul(2) });
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
@@ -734,16 +734,24 @@ You can also use this method to create new "dynamic" columns based on your exist
|
||||
For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
|
||||
To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string used to specify how the column is calculated.
|
||||
To create dynamic columns you can pass in a Map<string, string | Expr>. A column will be
|
||||
returned for each entry in the map. The key provides the name of the column. The value is
|
||||
an SQL string or an `Expr` that specifies how the column is calculated. An `Expr` built
|
||||
with `col` keeps the exact, case-sensitive column name.
|
||||
|
||||
For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
input to this method would be:
|
||||
input to this method would be `new Map([["combined", "a + b"], ["c", "c"]])`.
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string | Expr>` (e.g. an object literal). This
|
||||
method uses `Object.entries` which should preserve the insertion order of the object.
|
||||
However, object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string`> \| `Record`<`string`, `string`>
|
||||
* **columns**: `string` \| `string`[] \| `Map`<`string`, `string` \| [`Expr`](Expr.md)> \| `Record`<`string`, `string` \| [`Expr`](Expr.md)>
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -752,14 +760,8 @@ input to this method would be:
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
new Map([["combined", "a + b"], ["c", "c"]])
|
||||
|
||||
Columns will always be returned in the order given, even if that order is different than
|
||||
the order used when adding the data.
|
||||
|
||||
Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
table.query().select(new Map([["combined", "a + b"], ["c", "c"]]));
|
||||
table.query().select({ id: "id", doubled: col("unitPrice").mul(2) });
|
||||
```
|
||||
|
||||
#### Inherited from
|
||||
|
||||
@@ -26,8 +26,9 @@ How to return blob v2 columns. Applies to `toArrow()` and `toArray()`.
|
||||
called. All the bytes are held in memory.
|
||||
|
||||
Selecting a parent struct or directly aliasing a blob or struct also returns
|
||||
bytes. Blobs inside lists keep their descriptors. Arbitrary projection
|
||||
expressions are not materialized as bytes.
|
||||
bytes, including through an `Expr` that only references a column, such as
|
||||
`col("image")`. Blobs inside lists keep their descriptors. Arbitrary
|
||||
projection expressions are not materialized as bytes.
|
||||
|
||||
The rows and bytes come from the same snapshot. Remote queries require
|
||||
authoritative query version and snapshot identity headers, verified again
|
||||
|
||||
@@ -1736,6 +1736,13 @@ page).
|
||||
The tags API supports the standard CRUD operations (create, list, update, delete),
|
||||
plus checking out by tag name.
|
||||
|
||||
A tag identifies both a branch and a version. On Enterprise tables, a tag must belong
|
||||
to the handle's current branch; checking out a tag on another branch raises an
|
||||
error without changing the current selection. Obtain a handle for the tag's
|
||||
branch first: in Python, use `branch_table = table.branches.checkout("exp")`, then
|
||||
`branch_table.checkout("baseline")` to read a tag named `baseline` on `exp`.
|
||||
See [Branches](/tables/branching) for more on branch handles.
|
||||
|
||||
In Python, `tags.create()` accepts an optional `version`. If you omit it, the
|
||||
tag uses the version the table handle currently shows. That includes a handle
|
||||
checked out to an older version, so pass `version` explicitly when the tag must
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>com.lancedb</groupId>
|
||||
<artifactId>lancedb-parent</artifactId>
|
||||
<version>0.42.0-beta.37</version>
|
||||
<version>0.42.0-beta.38</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.37</version>
|
||||
<version>0.42.0-beta.38</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>16.0.0-beta.4</lance-core.version>
|
||||
<lance-core.version>16.0.0-beta.5</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.37"
|
||||
version = "0.42.0-beta.38"
|
||||
publish = false
|
||||
license.workspace = true
|
||||
description.workspace = true
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as http from "http";
|
||||
import type { AddressInfo } from "net";
|
||||
import * as tmp from "tmp";
|
||||
|
||||
import { type Table, connect } from "../lancedb";
|
||||
import { type Table, blob, connect } from "../lancedb";
|
||||
import {
|
||||
Table as ArrowTable,
|
||||
Field,
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
tableToIPC,
|
||||
} from "../lancedb/arrow";
|
||||
import { Expr, col, func, lit, litBool, litInt } from "../lancedb/expr";
|
||||
import { Index } from "../lancedb/indices";
|
||||
|
||||
describe("expr", () => {
|
||||
describe("col", () => {
|
||||
@@ -271,6 +272,171 @@ describe("expr", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("select", () => {
|
||||
let db: Awaited<ReturnType<typeof connect>>;
|
||||
let table: Table;
|
||||
let tmpDir: tmp.DirResult;
|
||||
|
||||
beforeAll(async () => {
|
||||
tmpDir = tmp.dirSync({ unsafeCleanup: true });
|
||||
db = await connect(tmpDir.name);
|
||||
table = await db.createTable("items", [
|
||||
{ id: 1, firstName: "Alice", unitPrice: 10, vector: [1, 0] },
|
||||
{ id: 2, firstName: "Bob", unitPrice: 20, vector: [0, 1] },
|
||||
{ id: 3, firstName: "Charlie", unitPrice: 30, vector: [-1, 0] },
|
||||
]);
|
||||
await table.createIndex("firstName", { config: Index.fts() });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
table.close();
|
||||
db.close();
|
||||
tmpDir.removeCallback();
|
||||
});
|
||||
|
||||
it("accepts Expr values in a Map, mixed with SQL strings", async () => {
|
||||
const rows = await table
|
||||
.query()
|
||||
.select(
|
||||
new Map<string, string | Expr>([
|
||||
["id", "id"],
|
||||
["name", col("firstName")],
|
||||
["doubled", col("unitPrice").mul(2)],
|
||||
]),
|
||||
)
|
||||
.toArray();
|
||||
expect(Object.keys(rows[0])).toEqual(["id", "name", "doubled"]);
|
||||
expect(rows.map((row) => [row.id, row.name, row.doubled])).toEqual([
|
||||
[1, "Alice", 20],
|
||||
[2, "Bob", 40],
|
||||
[3, "Charlie", 60],
|
||||
]);
|
||||
});
|
||||
|
||||
it("accepts Expr values in a Record, mixed with SQL strings", async () => {
|
||||
const [row] = await table
|
||||
.query()
|
||||
.where(col("firstName").eq("Bob"))
|
||||
.select({
|
||||
shout: col("firstName").upper(),
|
||||
quiet: func("lower", col("firstName")),
|
||||
id: "id",
|
||||
})
|
||||
.toArray();
|
||||
expect(Object.keys(row)).toEqual(["shout", "quiet", "id"]);
|
||||
expect([row.shout, row.quiet, row.id]).toEqual(["BOB", "bob", 2]);
|
||||
});
|
||||
|
||||
it("accepts Expr values in a vector query", async () => {
|
||||
const rows = await table
|
||||
.vectorSearch([1, 0])
|
||||
.select({ name: col("firstName"), doubled: col("unitPrice").mul(2) })
|
||||
.limit(1)
|
||||
.toArray();
|
||||
expect(rows).toHaveLength(1);
|
||||
expect([rows[0].name, rows[0].doubled]).toEqual(["Alice", 20]);
|
||||
});
|
||||
|
||||
it("accepts Expr values in an automatic search", async () => {
|
||||
const rows = await table
|
||||
.search("Bob")
|
||||
.select({ name: col("firstName"), doubled: col("unitPrice").mul(2) })
|
||||
.toArray();
|
||||
expect(rows).toHaveLength(1);
|
||||
expect([rows[0].name, rows[0].doubled]).toEqual(["Bob", 40]);
|
||||
});
|
||||
|
||||
it("accepts Expr values in a take query", async () => {
|
||||
const rows = await table
|
||||
.takeOffsets([2, 0])
|
||||
.select(
|
||||
new Map<string, string | Expr>([
|
||||
["name", col("firstName")],
|
||||
["doubled", col("unitPrice").mul(2)],
|
||||
]),
|
||||
)
|
||||
.toArray();
|
||||
expect(
|
||||
rows.map((row) => [row.name, row.doubled]).sort((a, b) => a[1] - b[1]),
|
||||
).toEqual([
|
||||
["Alice", 20],
|
||||
["Charlie", 60],
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects a value that is neither SQL nor an Expr", () => {
|
||||
const select = () => table.query().select({ id: 1 as unknown as string });
|
||||
expect(select).toThrow(TypeError);
|
||||
expect(select).toThrow(
|
||||
'select() values must be SQL strings or Expr objects, got number for "id"',
|
||||
);
|
||||
});
|
||||
|
||||
describe("with blobMode bytes", () => {
|
||||
const alpha = Buffer.from("alpha");
|
||||
const beta = Buffer.from("beta");
|
||||
let blobs: Table;
|
||||
|
||||
beforeAll(async () => {
|
||||
const schema = new Schema([
|
||||
new Field("id", new Int64(), true),
|
||||
blob("imageData"),
|
||||
]);
|
||||
blobs = await db.createTable(
|
||||
"blobs",
|
||||
[
|
||||
{ id: 1n, imageData: alpha },
|
||||
{ id: 2n, imageData: beta },
|
||||
],
|
||||
{ schema },
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
blobs.close();
|
||||
});
|
||||
|
||||
it("fills a camelCase blob column renamed with col()", async () => {
|
||||
const [row] = await blobs
|
||||
.query()
|
||||
.where("id = 2")
|
||||
.select(
|
||||
new Map<string, string | Expr>([
|
||||
["key", "id"],
|
||||
["picture", col("imageData")],
|
||||
]),
|
||||
)
|
||||
.toArray({ blobMode: "bytes" });
|
||||
expect(Object.keys(row)).toEqual(["key", "picture"]);
|
||||
expect(Number(row.key)).toBe(2);
|
||||
expect(Buffer.from(row.picture)).toEqual(beta);
|
||||
});
|
||||
|
||||
it("fills a blob column next to a computed Expr", async () => {
|
||||
const rows = await blobs
|
||||
.query()
|
||||
.select({ imageData: col("imageData"), next: col("id").add(1) })
|
||||
.toArray({ blobMode: "bytes" });
|
||||
expect(Object.keys(rows[0])).toEqual(["imageData", "next"]);
|
||||
expect(
|
||||
rows.map((row) => [Buffer.from(row.imageData), Number(row.next)]),
|
||||
).toEqual([
|
||||
[alpha, 2],
|
||||
[beta, 3],
|
||||
]);
|
||||
});
|
||||
|
||||
it("fills a blob column selected with col() in a take query", async () => {
|
||||
const rows = await blobs
|
||||
.takeOffsets([0])
|
||||
.select({ picture: col("imageData") })
|
||||
.toArray({ blobMode: "bytes" });
|
||||
expect(Object.keys(rows[0])).toEqual(["picture"]);
|
||||
expect(Buffer.from(rows[0].picture)).toEqual(alpha);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("sends a quoted expression value to remote as one literal", async () => {
|
||||
const value = "\\') OR true --";
|
||||
const schema = new Schema([
|
||||
|
||||
+44
-17
@@ -283,8 +283,9 @@ export interface QueryExecutionOptions {
|
||||
* called. All the bytes are held in memory.
|
||||
*
|
||||
* Selecting a parent struct or directly aliasing a blob or struct also returns
|
||||
* bytes. Blobs inside lists keep their descriptors. Arbitrary projection
|
||||
* expressions are not materialized as bytes.
|
||||
* bytes, including through an `Expr` that only references a column, such as
|
||||
* `col("image")`. Blobs inside lists keep their descriptors. Arbitrary
|
||||
* projection expressions are not materialized as bytes.
|
||||
*
|
||||
* The rows and bytes come from the same snapshot. Remote queries require
|
||||
* authoritative query version and snapshot identity headers, verified again
|
||||
@@ -416,34 +417,62 @@ export class QueryBase<
|
||||
* For example, you may not care about "a" or "b" but instead simply want "a + b". This is often
|
||||
* seen in the SELECT clause of an SQL query (e.g. `SELECT a+b FROM my_table`).
|
||||
*
|
||||
* To create dynamic columns you can pass in a Map<string, string>. A column will be returned
|
||||
* for each entry in the map. The key provides the name of the column. The value is
|
||||
* an SQL string used to specify how the column is calculated.
|
||||
* To create dynamic columns you can pass in a Map<string, string | Expr>. A column will be
|
||||
* returned for each entry in the map. The key provides the name of the column. The value is
|
||||
* an SQL string or an `Expr` that specifies how the column is calculated. An `Expr` built
|
||||
* with `col` keeps the exact, case-sensitive column name.
|
||||
*
|
||||
* For example, an SQL query might state `SELECT a + b AS combined, c`. The equivalent
|
||||
* input to this method would be:
|
||||
* @example
|
||||
* new Map([["combined", "a + b"], ["c", "c"]])
|
||||
* input to this method would be `new Map([["combined", "a + b"], ["c", "c"]])`.
|
||||
*
|
||||
* Columns will always be returned in the order given, even if that order is different than
|
||||
* the order used when adding the data.
|
||||
*
|
||||
* Note that you can pass in a `Record<string, string>` (e.g. an object literal). This method
|
||||
* uses `Object.entries` which should preserve the insertion order of the object. However,
|
||||
* object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
* Note that you can pass in a `Record<string, string | Expr>` (e.g. an object literal). This
|
||||
* method uses `Object.entries` which should preserve the insertion order of the object.
|
||||
* However, object insertion order is easy to get wrong and `Map` is more foolproof.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* table.query().select(new Map([["combined", "a + b"], ["c", "c"]]));
|
||||
* table.query().select({ id: "id", doubled: col("unitPrice").mul(2) });
|
||||
* ```
|
||||
*/
|
||||
select(
|
||||
columns: string[] | Map<string, string> | Record<string, string> | string,
|
||||
columns:
|
||||
| string[]
|
||||
| Map<string, string | Expr>
|
||||
| Record<string, string | Expr>
|
||||
| string,
|
||||
): this {
|
||||
const selectColumns = (columnArray: string[]) => {
|
||||
this.doCall((inner: NativeQueryType) => {
|
||||
inner.selectColumns(columnArray);
|
||||
});
|
||||
};
|
||||
const selectMapping = (columnTuples: [string, string][]) => {
|
||||
const selectMapping = (entries: [string, string | Expr][]) => {
|
||||
const columnTuples: [string, string][] = [];
|
||||
const sources: [string, string][] = [];
|
||||
for (const [name, value] of entries) {
|
||||
if (value instanceof Expr) {
|
||||
const sql = value.toSql();
|
||||
columnTuples.push([name, sql]);
|
||||
// toSql() quotes camelCase names and SQL keywords, so blobMode
|
||||
// matches a bare column reference by its plain name instead.
|
||||
sources.push([name, value.inner.columnName() ?? sql]);
|
||||
} else if (typeof value === "string") {
|
||||
columnTuples.push([name, value]);
|
||||
sources.push([name, value]);
|
||||
} else {
|
||||
throw new TypeError(
|
||||
`select() values must be SQL strings or Expr objects, got ${typeof value} for "${name}"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
this.doCall((inner: NativeQueryType) => {
|
||||
inner.select(columnTuples);
|
||||
});
|
||||
return sources;
|
||||
};
|
||||
|
||||
let projection: [string, string][];
|
||||
@@ -454,11 +483,9 @@ export class QueryBase<
|
||||
selectColumns(columns);
|
||||
projection = columns.map((column) => [column, column]);
|
||||
} else if (columns instanceof Map) {
|
||||
projection = Array.from(columns.entries());
|
||||
selectMapping(projection);
|
||||
projection = selectMapping(Array.from(columns.entries()));
|
||||
} else {
|
||||
projection = Object.entries(columns);
|
||||
selectMapping(projection);
|
||||
projection = selectMapping(Object.entries(columns));
|
||||
}
|
||||
if (this.blobContext !== undefined) {
|
||||
this.blobContext = { ...this.blobContext, projection };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-darwin-arm64",
|
||||
"version": "0.42.0-beta.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"os": ["darwin"],
|
||||
"cpu": ["arm64"],
|
||||
"main": "lancedb.darwin-arm64.node",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-linux-arm64-gnu",
|
||||
"version": "0.42.0-beta.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"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.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"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.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"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.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"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.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lancedb/lancedb-win32-x64-msvc",
|
||||
"version": "0.42.0-beta.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"os": ["win32"],
|
||||
"cpu": ["x64"],
|
||||
"main": "lancedb.win32-x64-msvc.node",
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
"ann"
|
||||
],
|
||||
"private": false,
|
||||
"version": "0.42.0-beta.37",
|
||||
"version": "0.42.0-beta.38",
|
||||
"main": "dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
|
||||
@@ -163,6 +163,15 @@ impl Expr {
|
||||
})
|
||||
}
|
||||
|
||||
/// The column name when this is a bare column reference, otherwise null.
|
||||
#[napi]
|
||||
pub fn column_name(&self) -> Option<String> {
|
||||
match &self.inner {
|
||||
DfExpr::Column(column) if column.relation.is_none() => Some(column.name.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn to_sql(&self) -> napi::Result<String> {
|
||||
lancedb::expr::expr_to_sql_string(&self.inner)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lancedb-python"
|
||||
version = "0.42.0-beta.37"
|
||||
version = "0.42.0-beta.38"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
description = "Python bindings for LanceDB"
|
||||
|
||||
@@ -64,7 +64,7 @@ tests = [
|
||||
"polars>=0.19, <=1.32.3",
|
||||
"pyarrow>=16",
|
||||
"pyarrow-stubs>=16.0",
|
||||
"pylance==16.0.0b4",
|
||||
"pylance==16.0.0b5",
|
||||
"requests>=2.31.0",
|
||||
"datafusion>=54,<55",
|
||||
"opentelemetry-sdk>=1.30.0",
|
||||
|
||||
@@ -3491,7 +3491,9 @@ class LanceHybridQueryBuilder(LanceQueryBuilder):
|
||||
fts_results = fts_results.set_column(
|
||||
score_i,
|
||||
fts_results.field(score_i),
|
||||
LanceHybridQueryBuilder._normalize_scores(fts_results.column(score_i)),
|
||||
LanceHybridQueryBuilder._normalize_scores(
|
||||
fts_results.column(score_i), tie_value=1.0
|
||||
),
|
||||
)
|
||||
|
||||
results = reranker.rerank_hybrid(fts_query, vector_results, fts_results)
|
||||
@@ -3552,7 +3554,9 @@ class LanceHybridQueryBuilder(LanceQueryBuilder):
|
||||
return results
|
||||
|
||||
@staticmethod
|
||||
def _normalize_scores(scores: pa.Array, invert=False) -> pa.Array:
|
||||
def _normalize_scores(
|
||||
scores: pa.Array, invert=False, tie_value: float = 0.0
|
||||
) -> pa.Array:
|
||||
if len(scores) == 0:
|
||||
return scores
|
||||
# normalize the scores by subtracting the min and dividing by the max
|
||||
@@ -3561,9 +3565,10 @@ class LanceHybridQueryBuilder(LanceQueryBuilder):
|
||||
|
||||
if not pc.equal(rng, pa.scalar(0.0)).as_py():
|
||||
scores = pc.divide(pc.subtract(scores, min), rng)
|
||||
elif not pc.equal(max, pa.scalar(0.0)).as_py():
|
||||
# If rng is 0, then we at least want the scores to be 0
|
||||
scores = pc.subtract(scores, min)
|
||||
else:
|
||||
# All scores are equal, so they are equally relevant. Distances
|
||||
# tie at 0 (best), while higher-is-better scores tie at 1.
|
||||
scores = pc.add(pc.subtract(scores, min), pa.scalar(tie_value, scores.type))
|
||||
|
||||
if invert:
|
||||
scores = pc.subtract(1, scores)
|
||||
|
||||
@@ -332,6 +332,16 @@ class RemoteTable(Table):
|
||||
)
|
||||
|
||||
def checkout(self, version: Union[int, str]):
|
||||
"""Check out a version number or tag as a read-only view in place.
|
||||
|
||||
A tag must belong to this handle's current branch. To read a tag on
|
||||
another branch, first obtain that branch's handle with
|
||||
`table.branches.checkout("branch_name")`, then call `checkout(tag)` on
|
||||
that handle. A tag on another branch raises an error without changing
|
||||
the current selection.
|
||||
|
||||
Call `checkout_latest()` to return to the latest version of this branch.
|
||||
"""
|
||||
result = LOOP.run(self._table.checkout(version))
|
||||
self._checkout_version = self.version
|
||||
return result
|
||||
|
||||
@@ -4247,6 +4247,12 @@ class Table(ABC):
|
||||
out state. To return the table to a normal state use
|
||||
`[Self::checkout_latest]`.
|
||||
|
||||
For Enterprise tables, a tag must belong to this handle's current branch.
|
||||
To read a tag on another branch, first obtain that branch's handle with
|
||||
`table.branches.checkout("branch_name")`, then call `checkout(tag)` on
|
||||
that handle. A tag on another branch raises an error without changing
|
||||
the current selection.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
version: int | str,
|
||||
@@ -10036,6 +10042,12 @@ class AsyncTable:
|
||||
out state. To return the table to a normal state use
|
||||
`[Self::checkout_latest]`.
|
||||
|
||||
For Enterprise tables, a tag must belong to this handle's current branch.
|
||||
To read a tag on another branch, first obtain that branch's handle with
|
||||
`await table.branches.checkout("branch_name")`, then call
|
||||
`await branch_table.checkout(tag)` on that handle. A tag on another
|
||||
branch raises an error without changing the current selection.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
version: int | str,
|
||||
|
||||
@@ -604,6 +604,37 @@ def test_normalize_scores():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("normalize", ["score", "rank"])
|
||||
def test_hybrid_single_fts_match_keeps_fts_weight(tmp_path, normalize):
|
||||
from lancedb.rerankers import LinearCombinationReranker
|
||||
|
||||
db = lancedb.connect(tmp_path)
|
||||
table = db.create_table(
|
||||
"test",
|
||||
[
|
||||
{"text": "apple banana", "vector": [0.0, 0.0]},
|
||||
{"text": "zebra unicorn", "vector": [0.1, 0.0]},
|
||||
{"text": "cherry grape", "vector": [5.0, 5.0]},
|
||||
],
|
||||
)
|
||||
table.create_fts_index("text")
|
||||
|
||||
results = (
|
||||
table.search(query_type="hybrid")
|
||||
.vector([0.0, 0.0])
|
||||
.text("zebra")
|
||||
.rerank(LinearCombinationReranker(weight=0.3), normalize=normalize)
|
||||
.limit(3)
|
||||
.to_arrow()
|
||||
)
|
||||
|
||||
assert results["text"].to_pylist() == [
|
||||
"zebra unicorn",
|
||||
"apple banana",
|
||||
"cherry grape",
|
||||
]
|
||||
|
||||
|
||||
def test_hybrid_query_rejects_query_with_vector(sync_table: Table):
|
||||
# Pins the full message: the space between "hybrid search." and "But" is
|
||||
# load-bearing (see the _validate_query literal concatenation).
|
||||
|
||||
Generated
+9
-9
@@ -1912,7 +1912,7 @@ requires-dist = [
|
||||
{ name = "pyarrow-stubs", marker = "extra == 'tests'", specifier = ">=16.0" },
|
||||
{ name = "pydantic", specifier = ">=2.7.4,<3" },
|
||||
{ name = "pylance", marker = "extra == 'pylance'", specifier = ">=16.0.0b2" },
|
||||
{ name = "pylance", marker = "extra == 'tests'", specifier = "==16.0.0b4" },
|
||||
{ name = "pylance", marker = "extra == 'tests'", specifier = "==16.0.0b5" },
|
||||
{ name = "pyright", marker = "extra == 'dev'", specifier = ">=1.1.350" },
|
||||
{ name = "pytest", marker = "extra == 'tests'", specifier = ">=7.0" },
|
||||
{ name = "pytest-asyncio", marker = "extra == 'tests'", specifier = ">=0.21" },
|
||||
@@ -3649,20 +3649,20 @@ crypto = [
|
||||
|
||||
[[package]]
|
||||
name = "pylance"
|
||||
version = "16.0.0b4"
|
||||
version = "16.0.0b5"
|
||||
source = { registry = "https://pypi.fury.io/lance-format/" }
|
||||
dependencies = [
|
||||
{ name = "lance-namespace" },
|
||||
{ name = "pyarrow" },
|
||||
]
|
||||
wheels = [
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_oJPBj/pylance-16.0.0b4-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:495789f4c6376aed8c5ad41fd04a828910120245e7d021cc2f59651f01ec7e45" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_bll8w/pylance-16.0.0b4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7579acd634b3d1513bb836d437d1f13bc4eb76625b0795e65b583007b16f223b" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_2d4iLq/pylance-16.0.0b4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5cf1c63d612ac36141399ceff30f46be16e537cd4d01562bc0453e8d79f19e8" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1X7cLu/pylance-16.0.0b4-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:b478f6ffef5a4e938e5578a6ec8f5b00866098b253daadd8f704008851d58417" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_pZ4HP/pylance-16.0.0b4-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:be9d95a9d22dad0371139faf982297cdd918aded1d59bc3ab4dd27394f55ba79" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1M3BoM/pylance-16.0.0b4-cp310-abi3-win_amd64.whl", hash = "sha256:1f84164d895df4522722cc7f8f10eaa42449c3c997f25476fb07ab48ef3b2969" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1AAGRf/pylance-16.0.0b4-cp310-abi3-win_arm64.whl", hash = "sha256:9423e6f4edef4f4048fab6cde69dd5cf2d2acdfc6dbe6171ce720753136b6b0a" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_FqwvG/pylance-16.0.0b5-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:9af1722a63e0955e4c0a5dc6e88a543a7a0a4e7b5684734259a7dda797093b10" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_ILl4l/pylance-16.0.0b5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:67d7cdc4cc05542bcab58fec45b221eb58f4d43f2913347f6438dce7104b3c2a" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_qJKmC/pylance-16.0.0b5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2f61729281f80c56ae5b2f237f6a4953f5499dbabda1c7d126942705665a2f1" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_2b3acP/pylance-16.0.0b5-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:25d6b502672bed79d32b7f07c580ec50228d52aaeb331b5a223b9b3956c4835e" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_quNgL/pylance-16.0.0b5-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:8d11aa27cb5e4ddbfa4051a4623f91b9a357c10e53989d4dccd5cdb20b904714" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_1X5vSy/pylance-16.0.0b5-cp310-abi3-win_amd64.whl", hash = "sha256:b814413dfc1bc67f6dba51e27d2826e576e4da4b8caf26964174709440d88db3" },
|
||||
{ url = "https://pypi.fury.io/lance-format/-/ver_ch7C5/pylance-16.0.0b5-cp310-abi3-win_arm64.whl", hash = "sha256:0f71399e92c9ad0832a761e613a0b5e696a28a2a958cef680ca572ebdeec12e4" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lancedb"
|
||||
version = "0.42.0-beta.37"
|
||||
version = "0.42.0-beta.38"
|
||||
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" = "=16.0.0-beta.4", "tag" = "v16.0.0-beta.4", "git" = "https://github.com/lance-format/lance.git" }
|
||||
lance-linalg = { "version" = "=16.0.0-beta.5", "tag" = "v16.0.0-beta.5", "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.37"
|
||||
version = "0.42.0-beta.38"
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
@@ -1269,7 +1269,7 @@ impl<S: HttpSend> RemoteTable<S> {
|
||||
}
|
||||
|
||||
/// Resolve a tag to its `(branch, version)` coordinate via the `tags/version`
|
||||
/// endpoint, since the `/branches/create` contract accepts no `from_tag`.
|
||||
/// endpoint.
|
||||
async fn resolve_tag_ref(&self, tag: &str) -> Result<(Option<String>, u64)> {
|
||||
let request = self
|
||||
.client
|
||||
@@ -4286,22 +4286,19 @@ impl<S: HttpSend> BaseTable for RemoteTable<S> {
|
||||
// Resolve the tag without attaching freshness headers; a stale
|
||||
// `min_version` from a previous write should not ride along on an
|
||||
// explicit time-travel request.
|
||||
let request = self
|
||||
.client
|
||||
.post(&format!("/v1/table/{}/tags/version/", self.identifier));
|
||||
let version = self
|
||||
.resolve_tag_version_with_request(tag, request, false)
|
||||
.await?;
|
||||
let (branch, version) = self.resolve_tag_ref(tag).await?;
|
||||
if branch != self.branch {
|
||||
return Err(Error::InvalidInput {
|
||||
message: format!(
|
||||
"Tag '{tag}' belongs to branch '{}', but this table handle is scoped to branch '{}'. Check out the tag's branch first.",
|
||||
branch.as_deref().unwrap_or("main"),
|
||||
self.branch.as_deref().unwrap_or("main"),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
let mut write_guard = self.version.write().await;
|
||||
// Commit the selector and its freshness mode while holding the selector
|
||||
// write lock, with no cancellation point between the two updates.
|
||||
self.reset_freshness(None, true);
|
||||
*write_guard = Some(version);
|
||||
self.invalidate_schema_cache();
|
||||
drop(write_guard);
|
||||
|
||||
Ok(())
|
||||
// Validate the version before pinning the handle.
|
||||
self.checkout(version).await
|
||||
}
|
||||
/// Only `OptimizeAction::Compact` with supported `options` and no custom
|
||||
/// `remap_options` is supported remotely: it submits a durable
|
||||
@@ -16191,12 +16188,13 @@ mod tests {
|
||||
.checkout_tag("v2")
|
||||
.await
|
||||
.expect("checkout_tag should succeed");
|
||||
assert_eq!(call_count.load(Ordering::SeqCst), 2);
|
||||
|
||||
// Schema call after checkout_tag should re-fetch (cache was invalidated)
|
||||
let schema3 = table.schema().await.unwrap();
|
||||
assert_eq!(
|
||||
call_count.load(Ordering::SeqCst),
|
||||
2,
|
||||
3,
|
||||
"Cache should have been invalidated and re-fetched"
|
||||
);
|
||||
assert_ne!(
|
||||
@@ -18130,12 +18128,13 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_freshness_checkout_tag_resolve_sends_no_min_version() {
|
||||
// Same invariant for checkout_tag: the tag-resolve request must not
|
||||
// pick up a stale min_version from a prior write.
|
||||
async fn test_freshness_checkout_tag_validation_sends_no_min_version() {
|
||||
// Neither the tag lookup nor the version validation should pick up a
|
||||
// stale min_version from a prior write.
|
||||
let (handler, captured) = path_capturing_handler(|path| match path {
|
||||
"/v1/table/my_table/update/" => r#"{"rows_updated":1,"version":7}"#.to_string(),
|
||||
"/v1/table/my_table/tags/version/" => r#"{"version":5}"#.to_string(),
|
||||
"/v1/table/my_table/describe/" => r#"{"version":5,"schema":{"fields":[]}}"#.to_string(),
|
||||
_ => panic!("unexpected path: {}", path),
|
||||
});
|
||||
let table = Table::new_with_handler("my_table", handler);
|
||||
@@ -18144,14 +18143,20 @@ mod tests {
|
||||
table.checkout_tag("v_initial").await.unwrap();
|
||||
|
||||
let captured = captured.lock().unwrap();
|
||||
let resolve_headers = captured
|
||||
.get("/v1/table/my_table/tags/version/")
|
||||
.expect("tags/version should have been called by checkout_tag");
|
||||
assert!(
|
||||
!resolve_headers.contains_key("x-lancedb-min-version"),
|
||||
"checkout_tag resolve must not carry stale min_version",
|
||||
);
|
||||
assert!(!resolve_headers.contains_key("x-lancedb-min-timestamp"));
|
||||
for path in [
|
||||
"/v1/table/my_table/tags/version/",
|
||||
"/v1/table/my_table/describe/",
|
||||
] {
|
||||
let headers = captured
|
||||
.get(path)
|
||||
.expect("checkout_tag should call endpoint");
|
||||
assert!(
|
||||
!headers.contains_key("x-lancedb-min-version"),
|
||||
"{path} must not carry stale min_version",
|
||||
);
|
||||
assert!(!headers.contains_key("x-lancedb-min-timestamp"));
|
||||
assert!(!headers.contains_key("x-lancedb-min-read-version"));
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -19017,6 +19022,221 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(None, Some("exp"))]
|
||||
#[case(Some("exp"), None)]
|
||||
#[case(Some("exp"), Some("main"))]
|
||||
#[case(Some("exp"), Some("other"))]
|
||||
#[tokio::test]
|
||||
async fn test_checkout_tag_rejects_other_branch(
|
||||
#[case] handle_branch: Option<&'static str>,
|
||||
#[case] tag_branch: Option<&'static str>,
|
||||
#[values(None, Some(1))] initial_version: Option<u64>,
|
||||
) {
|
||||
let table = RemoteTable::new_mock(
|
||||
"my_table".to_string(),
|
||||
move |request| {
|
||||
let body = request_body_json(&request);
|
||||
let response = match request.url().path() {
|
||||
"/v1/table/my_table/tags/version/" => {
|
||||
assert_eq!(body, json!({"tag": "cross_branch"}));
|
||||
json!({"branch": tag_branch, "version": 2}).to_string()
|
||||
}
|
||||
"/v1/table/my_table/describe/" => {
|
||||
assert_eq!(body["branch"].as_str(), handle_branch);
|
||||
assert_eq!(body["version"].as_u64(), initial_version);
|
||||
json!({"version": initial_version.unwrap_or(7), "schema": {"fields": []}})
|
||||
.to_string()
|
||||
}
|
||||
"/v1/table/my_table/count_rows/" => {
|
||||
assert_eq!(body["branch"].as_str(), handle_branch);
|
||||
assert_eq!(body["version"].as_u64(), initial_version);
|
||||
"3".to_string()
|
||||
}
|
||||
path => panic!("unexpected request: {path}"),
|
||||
};
|
||||
http::Response::builder()
|
||||
.status(200)
|
||||
.body(response)
|
||||
.unwrap()
|
||||
},
|
||||
None,
|
||||
)
|
||||
.with_branch(handle_branch.map(String::from));
|
||||
if let Some(version) = initial_version {
|
||||
table.checkout(version).await.unwrap();
|
||||
} else {
|
||||
table.checkout_latest().await.unwrap();
|
||||
}
|
||||
let schema = table.schema().await.unwrap();
|
||||
let before = table.snapshot_read_state().await;
|
||||
|
||||
let error = table.checkout_tag("cross_branch").await.unwrap_err();
|
||||
assert!(matches!(error, Error::InvalidInput { .. }), "{error:?}");
|
||||
let message = error.to_string();
|
||||
assert!(message.contains("cross_branch"), "{message}");
|
||||
assert!(message.contains(tag_branch.unwrap_or("main")), "{message}");
|
||||
assert!(
|
||||
message.contains(handle_branch.unwrap_or("main")),
|
||||
"{message}"
|
||||
);
|
||||
|
||||
let after = table.snapshot_read_state().await;
|
||||
assert_eq!(after.version, before.version);
|
||||
assert_eq!(
|
||||
after.freshness_state.generation,
|
||||
before.freshness_state.generation
|
||||
);
|
||||
assert_eq!(after.freshness_state.pinned, before.freshness_state.pinned);
|
||||
assert_eq!(
|
||||
after.freshness_state.min_version,
|
||||
before.freshness_state.min_version
|
||||
);
|
||||
assert_eq!(
|
||||
after.freshness_state.min_read_version,
|
||||
before.freshness_state.min_read_version
|
||||
);
|
||||
assert_eq!(
|
||||
after.freshness_state.checkout_baseline,
|
||||
before.freshness_state.checkout_baseline
|
||||
);
|
||||
assert_eq!(table.current_branch().as_deref(), handle_branch);
|
||||
assert!(Arc::ptr_eq(&schema, &table.schema().await.unwrap()));
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 3);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(None, None)]
|
||||
#[case(None, Some("main"))]
|
||||
#[case(None, Some(""))]
|
||||
#[case(None, Some(" main "))]
|
||||
#[case(Some("exp"), Some("exp"))]
|
||||
#[tokio::test]
|
||||
async fn test_checkout_tag_on_same_branch(
|
||||
#[case] handle_branch: Option<&'static str>,
|
||||
#[case] tag_branch: Option<&'static str>,
|
||||
) {
|
||||
let table = RemoteTable::new_mock(
|
||||
"my_table".to_string(),
|
||||
move |request| {
|
||||
let body = request_body_json(&request);
|
||||
let response = match request.url().path() {
|
||||
"/v1/table/my_table/tags/version/" => {
|
||||
assert_eq!(body, json!({"tag": "snapshot"}));
|
||||
json!({"branch": tag_branch, "version": 2}).to_string()
|
||||
}
|
||||
"/v1/table/my_table/describe/" => {
|
||||
assert_eq!(body["branch"].as_str(), handle_branch);
|
||||
assert_eq!(body["version"], 2);
|
||||
for header in [
|
||||
MIN_VERSION_HEADER,
|
||||
MIN_READ_VERSION_HEADER,
|
||||
MIN_TIMESTAMP_HEADER,
|
||||
] {
|
||||
assert!(!request.headers().contains_key(header));
|
||||
}
|
||||
r#"{"version":2,"schema":{"fields":[]}}"#.to_string()
|
||||
}
|
||||
"/v1/table/my_table/count_rows/" => {
|
||||
assert_eq!(body["branch"].as_str(), handle_branch);
|
||||
if body["version"].is_null() {
|
||||
"4".to_string()
|
||||
} else {
|
||||
assert_eq!(body["version"], 2);
|
||||
"3".to_string()
|
||||
}
|
||||
}
|
||||
path => panic!("unexpected request: {path}"),
|
||||
};
|
||||
http::Response::builder()
|
||||
.status(200)
|
||||
.body(response)
|
||||
.unwrap()
|
||||
},
|
||||
None,
|
||||
)
|
||||
.with_branch(handle_branch.map(String::from));
|
||||
|
||||
table.checkout_latest().await.unwrap();
|
||||
table.checkout_tag("snapshot").await.unwrap();
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 3);
|
||||
assert_eq!(table.current_branch().as_deref(), handle_branch);
|
||||
table.checkout_latest().await.unwrap();
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 4);
|
||||
assert_eq!(table.current_branch().as_deref(), handle_branch);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
#[case(None)]
|
||||
#[case(Some("exp"))]
|
||||
#[tokio::test]
|
||||
async fn test_checkout_tag_missing_version_leaves_handle_unchanged(
|
||||
#[case] branch: Option<&'static str>,
|
||||
#[values(None, Some(1))] initial_version: Option<u64>,
|
||||
) {
|
||||
let table = RemoteTable::new_mock(
|
||||
"my_table".to_string(),
|
||||
move |request| {
|
||||
let body = request_body_json(&request);
|
||||
if request.url().path() == "/v1/table/my_table/tags/version/" {
|
||||
return http::Response::builder()
|
||||
.status(200)
|
||||
.body(json!({"branch": branch, "version": 99}).to_string())
|
||||
.unwrap();
|
||||
}
|
||||
assert_eq!(body["branch"].as_str(), branch);
|
||||
if body["version"] == 99 {
|
||||
assert_eq!(request.url().path(), "/v1/table/my_table/describe/");
|
||||
return http::Response::builder()
|
||||
.status(404)
|
||||
.body("not found".to_string())
|
||||
.unwrap();
|
||||
}
|
||||
assert_eq!(body["version"].as_u64(), initial_version);
|
||||
let response = match request.url().path() {
|
||||
"/v1/table/my_table/describe/" => {
|
||||
json!({"version": initial_version.unwrap_or(7), "schema": {"fields": []}})
|
||||
.to_string()
|
||||
}
|
||||
"/v1/table/my_table/count_rows/" => "3".to_string(),
|
||||
path => panic!("unexpected request: {path}"),
|
||||
};
|
||||
http::Response::builder()
|
||||
.status(200)
|
||||
.body(response)
|
||||
.unwrap()
|
||||
},
|
||||
None,
|
||||
)
|
||||
.with_branch(branch.map(String::from));
|
||||
if let Some(version) = initial_version {
|
||||
table.checkout(version).await.unwrap();
|
||||
} else {
|
||||
table.checkout_latest().await.unwrap();
|
||||
}
|
||||
let schema = table.schema().await.unwrap();
|
||||
let before = table.snapshot_read_state().await;
|
||||
|
||||
let error = table.checkout_tag("missing_version").await.unwrap_err();
|
||||
assert!(matches!(error, Error::TableNotFound { .. }), "{error:?}");
|
||||
assert!(error.to_string().contains("version: 99"));
|
||||
let after = table.snapshot_read_state().await;
|
||||
assert_eq!(after.version, before.version);
|
||||
assert_eq!(
|
||||
after.freshness_state.generation,
|
||||
before.freshness_state.generation
|
||||
);
|
||||
assert_eq!(
|
||||
after.freshness_state.checkout_baseline,
|
||||
before.freshness_state.checkout_baseline
|
||||
);
|
||||
// HTTP errors invalidate the schema cache, but the refreshed schema
|
||||
// must still come from the original selector.
|
||||
assert_eq!(schema, table.schema().await.unwrap());
|
||||
assert_eq!(table.current_branch().as_deref(), branch);
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 3);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_checkout_branch_validates_via_list() {
|
||||
let table = Table::new_with_handler("my_table", |request| {
|
||||
|
||||
@@ -3075,6 +3075,10 @@ impl Table {
|
||||
|
||||
/// Checks out a specific version of the Table by tag
|
||||
///
|
||||
/// On Enterprise tables, the tag must belong to this handle's branch. Use
|
||||
/// [`Self::checkout_branch`] to obtain a handle for another branch first.
|
||||
/// A failed Enterprise tag checkout leaves the handle unchanged.
|
||||
///
|
||||
/// Any read operation on the table will now access the data at the version referenced by the tag.
|
||||
/// As a consequence, calling this method will disable any read consistency interval
|
||||
/// that was previously set.
|
||||
@@ -4801,6 +4805,7 @@ impl BaseTable for NativeTable {
|
||||
params: MergeInsertBuilder,
|
||||
new_data: Box<dyn RecordBatchReader + Send>,
|
||||
) -> Result<MergeResult> {
|
||||
self.dataset.ensure_mutable()?;
|
||||
let source_schema = arrow_array::RecordBatchReader::schema(&new_data);
|
||||
self.ensure_not_a_view("merge insert into").await?;
|
||||
computed_columns::ensure_not_written(
|
||||
@@ -6001,6 +6006,22 @@ mod tests {
|
||||
|
||||
// a pinned version is a detached head: writes are rejected
|
||||
assert!(pinned.add(sample_rows(vec![9])).execute().await.is_err());
|
||||
let exp_head = head.version().await.unwrap();
|
||||
for pinned_table in [&pinned, &pinned_direct] {
|
||||
let mut merge = pinned_table.merge_insert(&["i"]);
|
||||
merge
|
||||
.when_matched_update_all(None)
|
||||
.when_not_matched_insert_all();
|
||||
let err = merge.execute(sample_rows(vec![300])).await.unwrap_err();
|
||||
assert!(matches!(err, Error::InvalidInput { message }
|
||||
if message == "table cannot be modified when a specific version is checked out"));
|
||||
assert_eq!(pinned_table.version().await.unwrap(), exp_v2);
|
||||
assert_eq!(pinned_table.count_rows(None).await.unwrap(), 2);
|
||||
}
|
||||
assert_eq!(head.version().await.unwrap(), exp_head);
|
||||
assert_eq!(head.count_rows(None).await.unwrap(), 3);
|
||||
assert_eq!(table.version().await.unwrap(), main_v2);
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 4);
|
||||
|
||||
// version-only (no branch) time-travels main itself: its fork-point
|
||||
// version holds only main's first row, and the shared version number
|
||||
@@ -6386,8 +6407,35 @@ mod tests {
|
||||
.unwrap();
|
||||
let version = table.version().await.unwrap();
|
||||
table.add(some_sample_data()).execute().await.unwrap();
|
||||
let latest_version = table.version().await.unwrap();
|
||||
let opened = conn
|
||||
.open_table("my_table")
|
||||
.version(version)
|
||||
.execute()
|
||||
.await
|
||||
.unwrap();
|
||||
table.checkout(version).await.unwrap();
|
||||
assert!(table.add(some_sample_data()).execute().await.is_err())
|
||||
assert!(table.add(some_sample_data()).execute().await.is_err());
|
||||
for pinned_table in [&table, &opened] {
|
||||
let mut merge = pinned_table.merge_insert(&["i"]);
|
||||
merge
|
||||
.when_matched_update_all(None)
|
||||
.when_not_matched_insert_all();
|
||||
let err = merge.execute(sample_rows(vec![300])).await.unwrap_err();
|
||||
assert!(matches!(err, Error::InvalidInput { message }
|
||||
if message == "table cannot be modified when a specific version is checked out"));
|
||||
assert_eq!(pinned_table.version().await.unwrap(), version);
|
||||
assert_eq!(pinned_table.count_rows(None).await.unwrap(), 1);
|
||||
}
|
||||
|
||||
table.checkout_latest().await.unwrap();
|
||||
assert_eq!(table.version().await.unwrap(), latest_version);
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 2);
|
||||
let mut merge = table.merge_insert(&["i"]);
|
||||
merge.when_not_matched_insert_all();
|
||||
let result = merge.execute(sample_rows(vec![300])).await.unwrap();
|
||||
assert_eq!(result.num_inserted_rows, 1);
|
||||
assert_eq!(table.count_rows(None).await.unwrap(), 3);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lance-linalg"
|
||||
version = "16.0.0-beta.4"
|
||||
version = "16.0.0-beta.5"
|
||||
publish = false
|
||||
edition = { workspace = true }
|
||||
license = { workspace = true }
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
This directory contains `rust/lance-linalg` from Lance tag `v16.0.0-beta.4`
|
||||
(commit `1686234925dde0289409fa31ff615d724943ccb6`), licensed under Apache-2.0.
|
||||
This directory contains `rust/lance-linalg` from Lance tag `v16.0.0-beta.5`
|
||||
(commit `0ea718506941b3e4c8dd0aee279a8ea1b7c7b076`), 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