Draft
fix: preserve typed DataFusion errors through Shared and ReplayExec#8677
Conversation
- In error.rs: when Arc::try_unwrap fails for DataFusionError::Shared, re-wrap in DataFusionError::Shared and store as Error::External so the typed source chain is reachable via Error::source/downcast_ref. - In utils.rs: replace CloneableResult/CloneableError in the replay stream with Result<RecordBatch, Arc<DataFusionError>>. Errors are now wrapped with Arc::new and emitted as DataFusionError::Shared(arc), preserving the typed source for both ReplayExec consumers. Closes #8676 Co-authored-by: wjones127 <5488879+wjones127@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix error handling to preserve typed DataFusion errors
fix: preserve typed DataFusion errors through Shared and ReplayExec
Aug 20, 2026
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.
Two error paths erased the concrete type of a
DataFusionError, retaining only its display string—making it impossible for callers todowncast_refor walk the source chain to recover structured error information.Changes
lance-core/src/error.rs—DataFusionError::Sharedwith multiple ownersWhen
Arc::try_unwrapfails (the Arc has >1 owner), the previous fallback constructedError::Execution(shared.to_string()), dropping the typed inner error. Now it re-wraps the Arc asDataFusionError::Shared(shared)and stores it viaError::External, so the original type remains reachable throughError::source()/downcast_ref.lance/src/io/exec/utils.rs—ReplayExecshared streamShareableRecordBatchStreampreviously routed errors throughlance_core::Error+CloneableError. On clone,CloneableErrorfell through toError::cloned(to_string())forError::Externalvariants, discarding the type before the second consumer ever saw it.The stream now stores errors as
Arc<DataFusionError>(which isClone) and the adapter emits them asDataFusionError::Shared(arc). Both consumers share the same Arc and retain full access to the typed source chain.Tests
test_datafusion_shared_multi_owner_preserves_type(lance-core): verifies a marker error carried asDataFusionError::Externalsurvives conversion from a multiply-ownedDataFusionError::Shared.test_replay_preserves_typed_error(lance): verifies bothReplayExecpartitions candowncast_refto the original typed error.