Skip to content

fix(node): allow bigint[] for takeRowIds#2916

Merged
wjones127 merged 5 commits intolancedb:mainfrom
VedantMadane:fix/take-row-ids-bigint
Feb 3, 2026
Merged

fix(node): allow bigint[] for takeRowIds#2916
wjones127 merged 5 commits intolancedb:mainfrom
VedantMadane:fix/take-row-ids-bigint

Conversation

@VedantMadane
Copy link
Contributor

@VedantMadane VedantMadane commented Jan 16, 2026

Summary

This PR changes takeRowIds to accept bigint[] instead of
number[], matching the type of _rowid returned by withRowId().

Problem

When retrieving row IDs using \withRowId()\ and querying them back with takeRowIds(), users get an error because:

  1. _rowid values are returned as JavaScript bigint
  2. takeRowIds() expected number[]
  3. NAPI failed to convert: Error: Failed to convert napi value BigInt into rust type i64

Reproduction

\\js
import lancedb from '@lancedb/lancedb';

const db = await lancedb.connect('memory://');
const table = await db.createTable('test', [{ id: 1, vector: [1.0, 2.0] }]);

const results = await table.query().withRowId().toArray();
const rowIds = results.map(row => row._rowid);

console.log('types:', rowIds.map(id => typeof id)); // ['bigint']
await table.takeRowIds(rowIds).toArray(); // � Error before fix
\\

Solution

  • Updated TypeScript signature from takeRowIds(rowIds: number[]) to takeRowIds(rowIds: bigint[])
  • Updated Rust NAPI binding to accept Vec and convert using get_u64()

Fixes #2722

Change takeRowIds to accept bigint[] instead of number[], matching the
type of _rowid returned by withRowId().

Previously, attempting to use row IDs obtained from withRowId() would
fail with 'Failed to convert napi value BigInt into rust type i64'
because the NAPI binding expected number[] while _rowid values are
returned as bigint.

Fixes lancedb#2722
@github-actions github-actions bot added the bug Something isn't working label Jan 16, 2026
Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test for this?

- Test bigint[] input (main use case from issue lancedb#2722)
- Test number[] input for backwards compatibility
- Test mixed bigint/number arrays
- Test validation: non-integer, negative, unsafe large numbers
- Test negative bigint rejection from Rust layer
@VedantMadane
Copy link
Contributor Author

I'll add tests that cover using bigint[] directly, using number[] for backwards compatibility and validation errors for invalid inputs.
I think that covers everything required to test the takeRowIds functionality with bigint support.

Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks excellent. Thanks! Will merge once CI is passing.

@wjones127 wjones127 merged commit d3e15f3 into lancedb:main Feb 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(node): takeRowIds expect number instead of bigint

2 participants