lancedb / lancedb

Developer-friendly, serverless vector database for AI applications. Easily add long-term memory to your LLM apps!
https://lancedb.github.io/lancedb/
Apache License 2.0
4.69k stars 325 forks source link

bug(node): Error: Failed to convert JavaScript value `Object [10,10]` into rust type `String` #1661

Closed gy9527 closed 1 month ago

gy9527 commented 1 month ago

LanceDB version

0.10.0

What happened?

The example of table update will report an error

Are there known steps to reproduce?

import * as lancedb from "@lancedb/lancedb";

const db = await lancedb.connect("./.lancedb");

const data = [
    {x: 1, vector: [1, 2]},
    {x: 2, vector: [3, 4]},
    {x: 3, vector: [5, 6]},
];
const tbl = await db.createTable("my_table", data)

await tbl.update({vector: [10, 10]}, { where: "x = 2"})
wjones127 commented 1 month ago

Hello. There are two ways to pass new values in the update method: as SQL strings or as values. When you pass them in that overload, they are interpreted as SQL strings, which is why you get an error about converting to a string. If you want to pass Javascript values, instead use the values option:

table.update({ where: "x = 2", values: { vector: [10, 10] } })

https://lancedb.github.io/lancedb/js/classes/Table/#updateopts

gy9527 commented 1 month ago

table.update({ where: "x = 2", values: { vector: [10, -10] } })

If I change one of the values to a negative value, it will throw a new error: [Error: lance error: Invalid user input: LanceError(IO): Only arrays of literals are supported in lance.

I encountered this issue because in my project, the vector values have both positive and negative numbers, which results in the same error. How should I solve this?

wjones127 commented 1 month ago

Oh that is the same as https://github.com/lancedb/lancedb/issues/1501

Which has yet to be fixed upstream: https://github.com/lancedb/lance/issues/2695

I'll prioritize fixing that soon.