Skip to content

query: preserve SDK errors in lancedb_query_result_to_arrow - #136

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-lancedb-query-errors
Nov 22, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-lancedb-query-errors

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 22, 2026

Copy link
Copy Markdown
Member

Problem

lancedb_query_result_to_arrow replaced any error from draining the SDK stream with LANCEDB_UNKNOWN, losing the mapped code and the SDK diagnostic. It also published count and schema before the complete result was ready and left stale output slots or an error message in place.

Behavior

  • Drain errors go through handle_error, preserving the SDK error code and text.
  • Arrow schema C ABI conversion failures return LANCEDB_ARROW with the conversion detail.
  • Non-NULL output slots and the error message are cleared on entry; batches, schema and count are published only after the complete result is ready.
  • With all required pointers valid, the result is consumed on every path. A NULL result or output pointer returns LANCEDB_INVALID_ARGUMENT without consuming a non-NULL result, so the caller can still retry it or free it. Empty successful results keep their legacy NULL batches/schema and zero count.

Verification

  • cmake --build build --target lancedb_query_tests (Debug)
  • ./lancedb_query_tests — all 9 test cases and 20503 assertions pass
  • The new Catch2 regression drains a valid CAST(key AS INT) query and checks LANCEDB_LANCE, the cast diagnostic, and cleared outputs. Before this change the same query returned LANCEDB_UNKNOWN.

Refs #122

Route stream collection failures through handle_error so the SDK error code and message reach C callers instead of LANCEDB_UNKNOWN. Report schema C ABI conversion failures as LANCEDB_ARROW with the conversion detail.

Clear non-NULL output slots and the error message on entry. With all required output pointers valid, the result is consumed on every path; when a required output pointer is NULL, reject the call without consuming it so the caller can retry or free it. Publish batches, schema and count only after the complete result is ready.

Add a Catch2 regression that drains a valid query whose cast fails during execution and checks the mapped error, detail and cleared outputs.

Refs #122
@Xuanwo
Xuanwo merged commit f28249c into main Nov 22, 2026
9 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.

1 participant