Skip to content

fix: undefined values should become null in nullable fields#2658

Merged
wjones127 merged 7 commits intolancedb:mainfrom
nehaaprasad:fix/undef-null
Sep 23, 2025
Merged

fix: undefined values should become null in nullable fields#2658
wjones127 merged 7 commits intolancedb:mainfrom
nehaaprasad:fix/undef-null

Conversation

@nehaaprasad
Copy link
Copy Markdown
Contributor

Bug Fix: Undefined Values in Nullable Fields

Issue: When inserting data with undefined values into nullable fields, LanceDB was incorrectly coercing them to default values (false for booleans, NaN for numbers, "" for strings) instead of null.

Fix: Modified the makeVector() function in arrow.ts to properly convert undefined values to null for nullable fields before passing data to Apache Arrow.

fixes: #2645

Result: Now { text: undefined, number: undefined, bool: undefined } correctly becomes { text: null, number: null, bool: null } when fields are marked as nullable in the schema.

Files Changed:

  • nodejs/lancedb/arrow.ts (core fix)

  • nodejs/__test__/arrow.test.ts (test coverage)

  • This ensures proper null handling for nullable fields as expected by users.

@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.

Thanks for doing this. It looks like something went wrong with the formatter or linter and there are lot of irrelevant changes as well as a CI failure. Happy to merge once that is fixed.

Comment thread nodejs/__test__/arrow.test.ts Outdated
Comment on lines +1014 to +1015
// Test for the undefined values bug fix
describe("undefined values handling", () => {
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.

These are great tests!

Previously undefined values were coerced to default values (false, NaN, '')
instead of null for nullable fields. Now undefined values are properly
converted to null when fields are marked as nullable in the schema.
@nehaaprasad
Copy link
Copy Markdown
Contributor Author

@wjones127
fixed removed all formatting changes and CI issues.
PR now contains only the essential bug fix with clean commits.

@wjones127 wjones127 self-assigned this Sep 19, 2025
@wjones127 wjones127 merged commit b0800b4 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): passing undefined to nullable field gives coerced values

2 participants