fix: use typed NamespaceError::TableNotFound in DirectoryNamespace instead of plain strings#6267
Open
LuciferYang wants to merge 5 commits intolance-format:mainfrom
Conversation
Contributor
ReviewClean, well-scoped bugfix. The error conversion chain ( LGTM. 🤖 Generated with Claude Code |
7 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
Error::namespace_source(String)withNamespaceError::TableNotFoundindir.rsanddir/manifest.rsso that the JNI bridge can produce typed JavaTableNotFoundExceptioninstead of rawRuntimeException.Problem
When a table doesn't exist,
dir.rsanddir/manifest.rsconstruct errors like:This wraps a plain
StringasBox<dyn Error>. The JNI bridge (java/lance-jni/src/error.rs) tries to downcast the source toNamespaceErrorto throw a typedLanceNamespaceException(TABLE_NOT_FOUND), but the downcast fails on aStringand falls back toRuntimeException.The full typed error plumbing already exists —
NamespaceError::TableNotFound→lance_core::Error::Namespace(preserves theNamespaceError) → JNI downcast → JavaTableNotFoundException. Only the error construction at the call sites was missing it.This causes issues in the Spark connector (lance-format/lance-spark#217) where Spark 4.0+ expects
NoSuchTableExceptionfromloadTable()but getsRuntimeException, makingtableExists()crash instead of returningfalse.Fix
dir.rs: 3 occurrences —"Table does not exist: {table_name}"→NamespaceError::TableNotFound { message: table_name }dir/manifest.rs: 4 occurrences —"Table '{name}' not found"→NamespaceError::TableNotFound { message: name }dir.rsto match the new display format ("Table not found: ...")Test plan
test_describe_nonexistent_table— passes with updated assertiontest_table_exists— passes with updated assertiontest_table_exists_fails_for_deregistered_v1— passes (unchanged)test_convert_to_lance_errorin lance-namespace — confirms downcast chain workscargo check -p lance-namespace-impls— compiles cleanly