Skip to content

arrow: import Arrow C Stream batches - #147

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/arrow-c-stream-import-v2
Nov 22, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
xuanwo/arrow-c-stream-import-v2

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 22, 2026

Copy link
Copy Markdown
Member

Summary

Ready replacement for #144, rebuilt as one clean commit on actual main 55cd8a6. The old xuanwo/arrow-c-stream-import branch and #144 are left untouched.

  • Add lancedb_record_batch_reader_from_arrow_stream() for the write side of query: support Arrow C Data Stream (ArrowArrayStream) for streaming reads and writes #129. It moves a validated ArrowArrayStream into an existing LanceDBRecordBatchReader, acquires the schema once, pulls batches lazily, and preserves producer schema and read errors, including a NULL get_last_error result.
  • Validate required callbacks before taking ownership, clear the source release pointer, and release the producer exactly once after the move, including schema failure.
  • Reject top-level struct null rows after import and before extracting child columns, because a RecordBatch cannot represent them; nullable child fields, zero rows and a root validity bitmap with zero nulls remain valid.
  • Declare the standard Arrow C Data and Stream structures behind the shared inclusion guards, keep Doxygen from emitting duplicate typedef structs, and teach the ABI checker to resolve separate struct/typedef declarations. Both header inclusion orders work in C and C++.
  • Retain the original arrow: import Arrow C Stream batches #144 tests, headers, ABI checker and the current main Delta/DML integration; no unrelated changes.

The new root-null fixture now builds a consistent validity bitmap (all rows valid, only row zero cleared), runs ValidateFull(), and uses a local RAII table owner plus diagnostics so a failure reports its own cause and cleans up under Valgrind.

Tests

  • Real Arrow C++ ExportRecordBatchReader multi-batch data through table create, add and merge, checking actual row values.
  • Controlled producers cover schema acquisition, lazy reads, unused-reader release, callback validation before moving, one release after schema failure, read error text, NULL get_last_error, and zero-row batches.
  • Root-null struct fixture verifies rejection, unchanged table count/version and exactly one stream release.

Validation

  • cargo check --package lancedb-c
  • cargo fmt --check
  • ABI checks for host and x86_64-pc-windows-msvc (177 extern functions, 34 public structs, 7 shared enums)
  • C17 and C++20 tests for both lancedb/Arrow include orders, plus C17 consumer syntax
  • C++ test_arrow_stream.cpp syntax check
  • CMake docs target with Doxygen/Sphinx -W
  • Arrow-only root-null fixture run

Refs #144
Refs #129

Add lancedb_record_batch_reader_from_arrow_stream() for the write side of
#129. It moves a validated ArrowArrayStream into a LanceDBRecordBatchReader,
acquires the schema once, pulls batches lazily, and preserves producer
schema and read errors, including a NULL get_last_error result.

Validate required callbacks before taking ownership, clear the source
release pointer, and release the producer exactly once after the move,
including schema failure. Reject top-level struct null rows before
extracting child columns, because a RecordBatch cannot represent them.
Document the accepted RecordBatch shape and independent stream, schema and
array ownership.

Declare the standard Arrow C Data and Stream structures behind the shared
inclusion guards, keep Doxygen from emitting duplicate typedef structs, and
teach the ABI checker to resolve separate struct/typedef declarations.
Add real C++ multi-batch create/add/merge coverage plus focused ownership,
error and root-null fixtures.

This replacement is based on actual main 55cd8a6 and retains the original
#144 tests, headers, ABI checker and Delta/DML integration.

Refs #144
Refs #129
@Xuanwo
Xuanwo merged commit d9eb280 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