Skip to content

query: preserve SDK error code and message in lancedb_query_result_to_arrow #122

Done

Description

@Xuanwo

Context & SDK Reference

In src/query.rs (lancedb_query_result_to_arrow), when result_box.inner.try_collect().await fails while draining the SendableRecordBatchStream, the error is discarded and replaced with LanceDBError::Unknown and a generic unknown-error message:

Err(_) => {
    set_unknown_error_message(error_message);
    LanceDBError::Unknown
}

By contrast, lancedb_query_result_to_ipc_file in the same file properly forwards stream errors through handle_error(&error, error_message), preserving both the mapped LanceDBError code and the underlying SDK error message.

Proposed Fix

  • Route the stream collection error in lancedb_query_result_to_arrow through handle_error(&error, error_message) instead of collapsing it to LanceDBError::Unknown.
  • Clear *error_message on entry (consistent with lancedb_query_result_to_ipc_file) and ensure *batches_out, *schema_out, and *count_out are left in a well-defined empty/null state on error.
  • Route Arrow schema FFI conversion errors to LanceDBError::Arrow (or keep explicit error detail) rather than LanceDBError::Unknown.

Non-Goals

  • Changing the signature or ownership contract of lancedb_query_result_to_arrow (the result handle remains consumed on all non-null paths).
  • Adding streaming Arrow C Data Stream (ArrowArrayStream) support (tracked separately).

Acceptance Criteria

  • Failing stream execution in lancedb_query_result_to_arrow returns the SDK-mapped LanceDBError code and detailed error message via handle_error.
  • Catch2 C++ test verifies that a query failing during stream execution returns the expected non-LANCEDB_UNKNOWN error code and a descriptive error message, with no memory leaks under valgrind.

Activity

  1. added
    bug
    on Nov 22, 2026
  2. Xuanwo commented on Dec 1, 2026

    @Xuanwo
    MemberAuthor

    Fixed on main via #136 (f28249c9).

    lancedb_query_result_to_arrow now forwards the SDK-mapped error code and diagnostic, clears outputs, and reports Arrow schema conversion failures as LANCEDB_ARROW. A C++ regression test exercises a cast failure while draining a query stream and verifies LANCEDB_LANCE, the cast diagnostic, and cleared outputs.

    Verified on main by the passing Valgrind-enabled Ubuntu query suite. Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions