Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about inserting array in table #144

Closed
RicardoE105 opened this issue Dec 5, 2024 · 1 comment
Closed

Question about inserting array in table #144

RicardoE105 opened this issue Dec 5, 2024 · 1 comment

Comments

@RicardoE105
Copy link

I have a table with a single column(FLOAT[]). I'm trying to insert data using NodeJS as shown below, but get the following error when inserting:

[Error: Conversion Error: Type VARCHAR with value '2.3,2.2' can't be cast to the destination type ARRAY[2], the size of the array must match the destination type] {
errno: -1,
code: 'DUCKDB_NODEJS_ERROR',
errorType: 'Conversion'
}

Looks like the the array is being cast it to an sting. How to can insert the array 🤔 .

  const db = await Database.create('./sample-duckdb'); 

  
db.run(`
    CREATE TABLE embeddings (vector FLOAT[2]);
  `);

  const query = `INSERT INTO embeddings (vector) VALUES (?)`;

  (await db.prepare(query)).run([2.3,2.2]);
@RicardoE105
Copy link
Author

We need to JSON.stringify the object as suggested in #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant