Compare commits

...

9 Commits

Author SHA1 Message Date
Bert
2d49a26790 ensure table names are uri encoded for tables (#1189)
This prevents an issue where users can do something like:
```js
db.createTable('my-table#123123')
```
The server has logic to determine that '#' character is not allowed in
the table name, but currently this is being returned as 404 error
because it routes to `/v1/my-table#123123/create` and `#123123/create`
will not be parsed as part of path
2024-04-04 12:01:35 -07:00
qzhu
7f49f4cc35 add a default value for search.limit to be consistent with python sdk 2024-04-04 11:50:54 -07:00
Will Jones
8364d589ab feat: ship fp16kernels in Python wheels (#1148)
Same deal as https://github.com/lancedb/lance/pull/2098
2024-04-04 09:33:34 -07:00
Lei Xu
8687735bea chore: bump to 0.10.8 (#1187) 2024-04-03 16:52:32 -07:00
QianZhu
f0cd43da69 bug: fix the return value of countRows (#1186) 2024-04-03 16:31:49 -07:00
Lei Xu
7b954c7e3e chore: bump lance version (#1185)
Bump lance version to `0.10.7`
2024-04-03 14:46:05 -07:00
Bert
2579f29a92 fix error decoding in nodejs client (#1184)
fixes: #1183
2024-04-03 10:24:51 -04:00
QianZhu
7562b0fad1 remote count_rows need to return the number (#1181) 2024-04-02 13:12:22 -07:00
eduardjbotha
83b6b0d28a SQL Documentation includes DataFusion functions (#1179)
Show that it is possible to use the DataFusion functions in the `WHERE`
clause.

Co-authored-by: Eduard Botha <eduard.botha@inovex.de>
2024-04-02 07:49:48 -07:00
13 changed files with 77 additions and 40 deletions

View File

@@ -14,6 +14,10 @@ inputs:
# Note: this does *not* mean the host is arm64, since we might be cross-compiling. # Note: this does *not* mean the host is arm64, since we might be cross-compiling.
required: false required: false
default: "false" default: "false"
manylinux:
description: "The manylinux version to build for"
required: false
default: "2_17"
runs: runs:
using: "composite" using: "composite"
steps: steps:
@@ -28,7 +32,7 @@ runs:
command: build command: build
working-directory: python working-directory: python
target: x86_64-unknown-linux-gnu target: x86_64-unknown-linux-gnu
manylinux: "2_17" manylinux: ${{ inputs.manylinux }}
args: ${{ inputs.args }} args: ${{ inputs.args }}
before-script-linux: | before-script-linux: |
set -e set -e
@@ -43,7 +47,7 @@ runs:
command: build command: build
working-directory: python working-directory: python
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
manylinux: "2_24" manylinux: ${{ inputs.manylinux }}
args: ${{ inputs.args }} args: ${{ inputs.args }}
before-script-linux: | before-script-linux: |
set -e set -e

View File

@@ -6,13 +6,23 @@ on:
jobs: jobs:
linux: linux:
name: Python ${{ matrix.config.platform }} manylinux${{ matrix.config.manylinux }}
timeout-minutes: 60 timeout-minutes: 60
strategy: strategy:
matrix: matrix:
python-minor-version: ["8"] python-minor-version: ["8"]
platform: config:
- x86_64 - platform: x86_64
- aarch64 manylinux: "2_17"
extra_args: ""
- platform: x86_64
manylinux: "2_28"
extra_args: "--features fp16kernels"
- platform: aarch64
manylinux: "2_24"
extra_args: ""
# We don't build fp16 kernels for aarch64, because it uses
# cross compilation image, which doesn't have a new enough compiler.
runs-on: "ubuntu-22.04" runs-on: "ubuntu-22.04"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -26,8 +36,9 @@ jobs:
- uses: ./.github/workflows/build_linux_wheel - uses: ./.github/workflows/build_linux_wheel
with: with:
python-minor-version: ${{ matrix.python-minor-version }} python-minor-version: ${{ matrix.python-minor-version }}
args: "--release --strip" args: "--release --strip ${{ matrix.config.extra_args }}"
arm-build: ${{ matrix.platform == 'aarch64' }} arm-build: ${{ matrix.config.platform == 'aarch64' }}
manylinux: ${{ matrix.config.manylinux }}
- uses: ./.github/workflows/upload_wheel - uses: ./.github/workflows/upload_wheel
with: with:
token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }} token: ${{ secrets.LANCEDB_PYPI_API_TOKEN }}
@@ -58,7 +69,7 @@ jobs:
- uses: ./.github/workflows/build_mac_wheel - uses: ./.github/workflows/build_mac_wheel
with: with:
python-minor-version: ${{ matrix.python-minor-version }} python-minor-version: ${{ matrix.python-minor-version }}
args: "--release --strip --target ${{ matrix.config.target }}" args: "--release --strip --target ${{ matrix.config.target }} --features fp16kernels"
- uses: ./.github/workflows/upload_wheel - uses: ./.github/workflows/upload_wheel
with: with:
python-minor-version: ${{ matrix.python-minor-version }} python-minor-version: ${{ matrix.python-minor-version }}

View File

@@ -31,6 +31,10 @@ jobs:
run: run:
shell: bash shell: bash
working-directory: rust working-directory: rust
env:
# Need up-to-date compilers for kernels
CC: gcc-12
CXX: g++-12
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
@@ -54,6 +58,10 @@ jobs:
run: run:
shell: bash shell: bash
working-directory: rust working-directory: rust
env:
# Need up-to-date compilers for kernels
CC: gcc-12
CXX: g++-12
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:

View File

@@ -14,10 +14,10 @@ keywords = ["lancedb", "lance", "database", "vector", "search"]
categories = ["database-implementations"] categories = ["database-implementations"]
[workspace.dependencies] [workspace.dependencies]
lance = { "version" = "=0.10.6", "features" = ["dynamodb"] } lance = { "version" = "=0.10.8", "features" = ["dynamodb"] }
lance-index = { "version" = "=0.10.6" } lance-index = { "version" = "=0.10.8" }
lance-linalg = { "version" = "=0.10.6" } lance-linalg = { "version" = "=0.10.8" }
lance-testing = { "version" = "=0.10.6" } lance-testing = { "version" = "=0.10.8" }
# Note that this one does not include pyarrow # Note that this one does not include pyarrow
arrow = { version = "50.0", optional = false } arrow = { version = "50.0", optional = false }
arrow-array = "50.0" arrow-array = "50.0"

View File

@@ -66,6 +66,7 @@ Currently, Lance supports a growing list of SQL expressions.
- `LIKE`, `NOT LIKE` - `LIKE`, `NOT LIKE`
- `CAST` - `CAST`
- `regexp_match(column, pattern)` - `regexp_match(column, pattern)`
- [DataFusion Functions](https://arrow.apache.org/datafusion/user-guide/sql/scalar_functions.html)
For example, the following filter string is acceptable: For example, the following filter string is acceptable:

View File

@@ -38,7 +38,7 @@ export class Query<T = number[]> {
constructor (query?: T, tbl?: any, embeddings?: EmbeddingFunction<T>) { constructor (query?: T, tbl?: any, embeddings?: EmbeddingFunction<T>) {
this._tbl = tbl this._tbl = tbl
this._query = query this._query = query
this._limit = undefined this._limit = 10
this._nprobes = 20 this._nprobes = 20
this._refineFactor = undefined this._refineFactor = undefined
this._select = undefined this._select = undefined

View File

@@ -103,6 +103,18 @@ function toLanceRes (res: AxiosResponse): RemoteResponse {
} }
} }
async function decodeErrorData(
res: RemoteResponse,
responseType?: ResponseType
): Promise<string> {
const errorData = await res.body()
if (responseType === 'arraybuffer') {
return new TextDecoder().decode(errorData)
} else {
return errorData
}
}
export class HttpLancedbClient { export class HttpLancedbClient {
private readonly _url: string private readonly _url: string
private readonly _apiKey: () => string private readonly _apiKey: () => string
@@ -180,7 +192,7 @@ export class HttpLancedbClient {
} }
if (response.status !== 200) { if (response.status !== 200) {
const errorData = new TextDecoder().decode(await response.body()) const errorData = await decodeErrorData(response)
throw new Error( throw new Error(
`Server Error, status: ${response.status}, ` + `Server Error, status: ${response.status}, ` +
`message: ${response.statusText}: ${errorData}` `message: ${response.statusText}: ${errorData}`
@@ -226,7 +238,7 @@ export class HttpLancedbClient {
} }
if (response.status !== 200) { if (response.status !== 200) {
const errorData = new TextDecoder().decode(await response.body()) const errorData = await decodeErrorData(response, responseType)
throw new Error( throw new Error(
`Server Error, status: ${response.status}, ` + `Server Error, status: ${response.status}, ` +
`message: ${response.statusText}: ${errorData}` `message: ${response.statusText}: ${errorData}`

View File

@@ -156,7 +156,7 @@ export class RemoteConnection implements Connection {
} }
const res = await this._client.post( const res = await this._client.post(
`/v1/table/${tableName}/create/`, `/v1/table/${encodeURIComponent(tableName)}/create/`,
buffer, buffer,
undefined, undefined,
'application/vnd.apache.arrow.stream' 'application/vnd.apache.arrow.stream'
@@ -177,7 +177,7 @@ export class RemoteConnection implements Connection {
} }
async dropTable (name: string): Promise<void> { async dropTable (name: string): Promise<void> {
await this._client.post(`/v1/table/${name}/drop/`) await this._client.post(`/v1/table/${encodeURIComponent(name)}/drop/`)
} }
withMiddleware (middleware: HttpMiddleware): Connection { withMiddleware (middleware: HttpMiddleware): Connection {
@@ -268,7 +268,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
get schema (): Promise<any> { get schema (): Promise<any> {
return this._client return this._client
.post(`/v1/table/${this._name}/describe/`) .post(`/v1/table/${encodeURIComponent(this._name)}/describe/`)
.then(async (res) => { .then(async (res) => {
if (res.status !== 200) { if (res.status !== 200) {
throw new Error( throw new Error(
@@ -282,7 +282,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
} }
search (query: T): Query<T> { search (query: T): Query<T> {
return new RemoteQuery(query, this._client, this._name) //, this._embeddings_new) return new RemoteQuery(query, this._client, encodeURIComponent(this._name)) //, this._embeddings_new)
} }
filter (where: string): Query<T> { filter (where: string): Query<T> {
@@ -324,7 +324,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
const buffer = await fromTableToStreamBuffer(tbl, this._embeddings) const buffer = await fromTableToStreamBuffer(tbl, this._embeddings)
const res = await this._client.post( const res = await this._client.post(
`/v1/table/${this._name}/merge_insert/`, `/v1/table/${encodeURIComponent(this._name)}/merge_insert/`,
buffer, buffer,
queryParams, queryParams,
'application/vnd.apache.arrow.stream' 'application/vnd.apache.arrow.stream'
@@ -348,7 +348,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
const buffer = await fromTableToStreamBuffer(tbl, this._embeddings) const buffer = await fromTableToStreamBuffer(tbl, this._embeddings)
const res = await this._client.post( const res = await this._client.post(
`/v1/table/${this._name}/insert/`, `/v1/table/${encodeURIComponent(this._name)}/insert/`,
buffer, buffer,
{ {
mode: 'append' mode: 'append'
@@ -374,7 +374,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
} }
const buffer = await fromTableToStreamBuffer(tbl, this._embeddings) const buffer = await fromTableToStreamBuffer(tbl, this._embeddings)
const res = await this._client.post( const res = await this._client.post(
`/v1/table/${this._name}/insert/`, `/v1/table/${encodeURIComponent(this._name)}/insert/`,
buffer, buffer,
{ {
mode: 'overwrite' mode: 'overwrite'
@@ -421,7 +421,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
index_cache_size: indexCacheSize index_cache_size: indexCacheSize
} }
const res = await this._client.post( const res = await this._client.post(
`/v1/table/${this._name}/create_index/`, `/v1/table/${encodeURIComponent(this._name)}/create_index/`,
data data
) )
if (res.status !== 200) { if (res.status !== 200) {
@@ -442,7 +442,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
replace: true replace: true
} }
const res = await this._client.post( const res = await this._client.post(
`/v1/table/${this._name}/create_scalar_index/`, `/v1/table/${encodeURIComponent(this._name)}/create_scalar_index/`,
data data
) )
if (res.status !== 200) { if (res.status !== 200) {
@@ -455,14 +455,14 @@ export class RemoteTable<T = number[]> implements Table<T> {
} }
async countRows (filter?: string): Promise<number> { async countRows (filter?: string): Promise<number> {
const result = await this._client.post(`/v1/table/${this._name}/count_rows/`, { const result = await this._client.post(`/v1/table/${encodeURIComponent(this._name)}/count_rows/`, {
predicate: filter predicate: filter
}) })
return (await result.body())?.stats?.num_rows return (await result.body())
} }
async delete (filter: string): Promise<void> { async delete (filter: string): Promise<void> {
await this._client.post(`/v1/table/${this._name}/delete/`, { await this._client.post(`/v1/table/${encodeURIComponent(this._name)}/delete/`, {
predicate: filter predicate: filter
}) })
} }
@@ -481,7 +481,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
updates[key] = toSQL(value) updates[key] = toSQL(value)
} }
} }
await this._client.post(`/v1/table/${this._name}/update/`, { await this._client.post(`/v1/table/${encodeURIComponent(this._name)}/update/`, {
predicate: filter, predicate: filter,
updates: Object.entries(updates).map(([key, value]) => [key, value]) updates: Object.entries(updates).map(([key, value]) => [key, value])
}) })
@@ -489,7 +489,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
async listIndices (): Promise<VectorIndex[]> { async listIndices (): Promise<VectorIndex[]> {
const results = await this._client.post( const results = await this._client.post(
`/v1/table/${this._name}/index/list/` `/v1/table/${encodeURIComponent(this._name)}/index/list/`
) )
return (await results.body()).indexes?.map((index: any) => ({ return (await results.body()).indexes?.map((index: any) => ({
columns: index.columns, columns: index.columns,
@@ -500,7 +500,7 @@ export class RemoteTable<T = number[]> implements Table<T> {
async indexStats (indexUuid: string): Promise<IndexStats> { async indexStats (indexUuid: string): Promise<IndexStats> {
const results = await this._client.post( const results = await this._client.post(
`/v1/table/${this._name}/index/${indexUuid}/stats/` `/v1/table/${encodeURIComponent(this._name)}/index/${indexUuid}/stats/`
) )
const body = await results.body() const body = await results.body()
return { return {

View File

@@ -31,3 +31,6 @@ pyo3-build-config = { version = "0.20.3", features = [
"extension-module", "extension-module",
"abi3-py38", "abi3-py38",
] } ] }
[features]
fp16kernels = ["lancedb/fp16kernels"]

View File

@@ -3,7 +3,7 @@ name = "lancedb"
version = "0.6.6" version = "0.6.6"
dependencies = [ dependencies = [
"deprecation", "deprecation",
"pylance==0.10.6", "pylance==0.10.8",
"ratelimiter~=1.0", "ratelimiter~=1.0",
"retry>=0.9.2", "retry>=0.9.2",
"tqdm>=4.27.0", "tqdm>=4.27.0",
@@ -41,6 +41,7 @@ classifiers = [
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering",
] ]

View File

@@ -500,7 +500,10 @@ class RemoteTable(Table):
def count_rows(self, filter: Optional[str] = None) -> int: def count_rows(self, filter: Optional[str] = None) -> int:
payload = {"predicate": filter} payload = {"predicate": filter}
self._conn._client.post(f"/v1/table/{self._name}/count_rows/", data=payload) resp = self._conn._client.post(
f"/v1/table/{self._name}/count_rows/", data=payload
)
return resp
def add_columns(self, transforms: Dict[str, str]): def add_columns(self, transforms: Dict[str, str]):
raise NotImplementedError( raise NotImplementedError(

View File

@@ -50,3 +50,4 @@ walkdir = "2"
[features] [features]
default = ["remote"] default = ["remote"]
remote = ["dep:reqwest"] remote = ["dep:reqwest"]
fp16kernels = ["lance-linalg/fp16kernels"]

View File

@@ -1304,14 +1304,7 @@ impl TableInternal for NativeTable {
} }
async fn count_rows(&self, filter: Option<String>) -> Result<usize> { async fn count_rows(&self, filter: Option<String>) -> Result<usize> {
let dataset = self.dataset.get().await?; Ok(self.dataset.get().await?.count_rows(filter).await?)
if let Some(filter) = filter {
let mut scanner = dataset.scan();
scanner.filter(&filter)?;
Ok(scanner.count_rows().await? as usize)
} else {
Ok(dataset.count_rows().await?)
}
} }
async fn add( async fn add(