Skip to content

fix(node): handle null values in nullable boolean fields#2657

Merged
wjones127 merged 3 commits intolancedb:mainfrom
nehaaprasad:fix-bool-null
Sep 23, 2025
Merged

fix(node): handle null values in nullable boolean fields#2657
wjones127 merged 3 commits intolancedb:mainfrom
nehaaprasad:fix-bool-null

Conversation

@nehaaprasad
Copy link
Copy Markdown
Contributor

@nehaaprasad nehaaprasad commented Sep 15, 2025

Solution

Added special handling in makeVector function for boolean arrays where all values are null. The fix creates a proper null bitmap using makeData and arrowMakeVector instead of relying on Apache Arrow's vectorFromArray which doesn't handle this edge case correctly.

fixes: #2644

Changes

  • Added null value detection for boolean types in makeVector function

  • Creates proper Arrow data structure with null bitmap when all boolean values are null

  • Preserves existing behavior for non-null boolean values and other data types

  • Fixes the boolean null value bug while maintaining backward compatibility.

@github-actions github-actions Bot added the bug Something isn't working label Sep 15, 2025
Copy link
Copy Markdown
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.

This seems like it should work. Could you add a unit test for it though?

Comment thread nodejs/lancedb/arrow.ts
// biome-ignore lint/suspicious/noExplicitAny: skip
): Vector<any> {
if (type !== undefined) {
if (DataType.isBool(type)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a comment saying this is a workaround for this issue in arrow? That way we can one day remove once this is fixed upstream.

Suggested change
if (DataType.isBool(type)) {
// Workaround for: https://github.com/apache/arrow-js/issues/68
if (DataType.isBool(type)) {

…dling

- Add GitHub issue reference for the arrow-js workaround
- Add unit tests for null boolean values and mixed boolean arrays
- Addresses reviewer feedback
@nehaaprasad
Copy link
Copy Markdown
Contributor Author

@wjones127
i have added the workaround comment with GitHub issue link and comprehensive unit tests for boolean null handling as requested.

@wjones127 wjones127 self-assigned this Sep 19, 2025
@wjones127 wjones127 merged commit 1befebf into lancedb:main Sep 23, 2025
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): can't pass null to nullable boolean field

2 participants