Feat/dotnet arrow streams - #541
Open
nalyd2 wants to merge 4 commits into
Open
Conversation
Add Arrow Flight ingestion streams (ZerobusArrowStream) with IPC compression support, thread-safe lifecycle, and OAuth/headers-provider authentication. Includes ArrowStreamConfigurationOptions record. Add ProtoSchema class for generating protobuf schemas from Unity Catalog table metadata, including descriptor byte extraction and JSON-to-protobuf encoding. Signed-off-by: nalyd2 <jazer_252_@hotmail.com>
Add fluent StreamBuilder API as an alternative to ZerobusSdk factory methods. Supports chaining .Table(), .OAuth(), .MaxInflightRequests(), .Recovery() etc. with typed sub-builders for JSON, Proto, and Arrow. Add async operations to ZerobusArrowStream: IngestBatchAsync, WaitForOffsetAsync, FlushAsync, CloseAsync, GetUnackedBatchesAsync. Add integration tests for Arrow streams and StreamBuilder validation. Includes 25 new unit tests and 15 integration tests. Signed-off-by: nalyd2 <jazer_252_@hotmail.com>
Add ProtoSchema example with dual path: - Option A: fetch Unity Catalog table metadata via Databricks REST API (requires DATABRICKS_TOKEN env var) - Option B: inline JSON fallback for development/CI Full workflow: UC JSON → ProtoSchema → descriptor → proto stream → EncodeJson (JSON to protobuf conversion) → ingest → flush. Update README: StreamBuilder and factory methods in Quick Start, Arrow Flight API reference, ProtoSchema section, ArrowStreamConfigurationOptions table, updated project structure. Signed-off-by: nalyd2 <jazer_252_@hotmail.com>
Implement MockFlightServer using Apache.Arrow.Flight.AspNetCore that extends FlightServer and handles the Arrow Flight DoPut protocol. Enables all 18 Arrow integration tests to run against the local mock server instead of skipping. - Add MockFlightServer implementing FlightServer.DoPut with: - Stream-ready signal (ack_up_to_offset=-1) after schema - Per-batch acknowledgements with offset_id from app_metadata - Graceful handling of client disconnect (no-data tests) - Register MockFlightServer in MockServerFixture via AddFlightServer<T> and MapFlightEndpoint, serving on the same port as MockZerobusServer - Add Apache.Arrow.Flight and Apache.Arrow.Flight.AspNetCore v19.0.0 - Fix JSON serialization to use snake_case (Rust SDK serde expects ack_up_to_offset / ack_up_to_records) - Replace raw byte arrays with valid Arrow IPC batch bytes in tests - Add assertions against ArrowFlightServer state (BatchesReceived, MaxOffsetSeen) - Remove all Assert.Ignore skip logic -- all 18 Arrow tests now pass Signed-off-by: nalyd2 <jazer_252_@hotmail.com>
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.
What changes are proposed in this pull request?
This PR adds Arrow Flight ingestion stream support, ProtoSchema, a fluent StreamBuilder API, async Arrow operations, and a MockFlightServer for integration testing to the .NET SDK.
Major changes:
Arrow Flight streams (
ZerobusArrowStream)IngestBatch(byte[]),Flush(),Close(),GetUnackedBatches()IngestBatchAsync,WaitForOffsetAsync,FlushAsync,CloseAsyncArrowStreamConfigurationOptionsrecord with IPC compression (None, LZ4_FRAME, ZSTD)ArrowBatchInforecord for unacknowledged batch recoveryIPCCompressionTypeenumProtoSchema
FromUnityCatalogJson(string)— generates protobuf schemas from Unity Catalog API responsesGetDescriptorBytes()— returns compiledFileDescriptorProtobytes for stream creationEncodeJson(string)— converts JSON records to protobuf bytes matching the table schemaFluent StreamBuilder API
sdk.StreamBuilder().Table(...).OAuth(...).Json().Build()JsonStreamBuilder,ProtoStreamBuilder,ArrowStreamBuilderCreateJsonStream,CreateProtoStream,CreateArrowStream)MockFlightServer (integration tests)
DoPutprotocol usingApache.Arrow.Flight.AspNetCoreack_up_to_offset=-1) and per-batch acknowledgementsMockServerFixturealongside the existing JSON/Proto mockWhy: These features enable high-performance Arrow columnar ingestion into Databricks Delta tables, runtime protobuf schema generation from Unity Catalog (no local
.protocompilation needed), and a discoverable fluent API for stream creation. The MockFlightServer unblocks Arrow integration testing without requiring a real Databricks endpoint.Note: This work continues from the discussion in #532, which was superseded by #536. The features here (Arrow Flight streams, ProtoSchema, StreamBuilder, MockFlightServer) are additional contributions on top of the merged codebase.
How is this tested?
140 tests passing (0 skipped, 0 failed):
Zerobus.Tests)Zerobus.IntegrationTests)New tests added (43 total):
StreamBuilderTests.cs— 13 tests (fluent API, null checks, return types)ArrowStreamConfigurationOptionsTests.cs— 6 tests (defaults, with expressions, IPC enum)ArrowBatchInfoTests.cs— 2 tests (record equality)ProtoSchemaTests.cs— 4 tests (argument validation, API surface)ArrowIntegrationTests.cs— 18 tests (create, ingest, flush, close, async, multiple batches, mock server assertions)Test infrastructure:
MockZerobusServer— gRPC mock for JSON/Proto (existing)MockFlightServer— gRPC mock for Arrow Flight DoPut (new, this PR)net8.0andnet10.0