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

feat: forbid creating index if num_sub_vectors doesn't divide dim #2234

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

BubbleCal
Copy link
Contributor

@BubbleCal BubbleCal commented Apr 20, 2024

see details: lancedb/lancedb#1222

Signed-off-by: BubbleCal <bubble-cal@outlook.com>
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.08%. Comparing base (a5171b9) to head (9a4396b).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2234      +/-   ##
==========================================
- Coverage   81.11%   81.08%   -0.04%     
==========================================
  Files         185      186       +1     
  Lines       53411    53575     +164     
  Branches    53411    53575     +164     
==========================================
+ Hits        43324    43439     +115     
- Misses       7605     7669      +64     
+ Partials     2482     2467      -15     
Flag Coverage Δ
unittests 81.08% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if data.num_columns() % m != 0 {
return Err(Error::invalid_input(
format!(
"num_sub_vectors must divide vector dimension {}, but got {}",
Copy link

Choose a reason for hiding this comment

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

If possible, I might refer the user in a section to the docs that explains this in more detail. I'd imagine that some users just run the index command expecting it to work, and if it doesn't they probably need more than this message to debug it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, we don't yet have a docs page that describes this well. We should add that, but this seems like a definite improvement over the current panics.

@wjones127 wjones127 changed the title chore: forbid creating index if num_sub_vectors doesn't divide dim feat: forbid creating index if num_sub_vectors doesn't divide dim Apr 22, 2024
Comment on lines 2236 to 2239
assert!(dataset
.create_index(&["vector"], IndexType::Vector, None, &params, false)
.await
.is_err());
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to also assert the error message:

Suggested change
assert!(dataset
.create_index(&["vector"], IndexType::Vector, None, &params, false)
.await
.is_err());
let res = dataset
.create_index(&["vector"], IndexType::Vector, None, &params, false)
.await;
assert!(
matches!(res, Err(Error::InvalidInput { source, .. }
if source.to_string().contains("num_sub_vectors must divide vector dimension"))),
"{:?}",
&res
);

Signed-off-by: BubbleCal <bubble-cal@outlook.com>
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
@BubbleCal BubbleCal merged commit 5c77425 into lancedb:main Apr 24, 2024
17 checks passed
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

Successfully merging this pull request may close these issues.

None yet

4 participants