Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/amp/src/arrow-flight/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ const make = Effect.gen(function* () {
return flightDataStream.pipe(
Stream.mapEffect(
Effect.fnUntraced(function* (flightData): Effect.fn.Return<Option.Option<Result>, ArrowFlightError> {
// Amp sends keep-alive frames with no IPC message on long-lived streams
if (flightData.dataHeader.length === 0) {
return Option.none<Result>()
}

const messageType = yield* Effect.orDie(getMessageType(flightData))

switch (messageType) {
Expand Down
29 changes: 29 additions & 0 deletions packages/amp/test/arrow-flight/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,33 @@ describe("ArrowFlight", () => {
expect(results[0]?.data).toEqual([{ bin: toHex(firstExpected) }])
})
)

it.effect("skips keep-alive frames", ({ expect }) =>
Effect.gen(function* () {
const testSchema = SchemaBuilder.schema().int32("id", { nullable: false }).build()

const generated = yield* FlightDataGenerator.generateFlightData(testSchema, {
numRows: 3,
seed: 144
})

const keepAlive = create(FlightDataSchema, {})
const transport = makeTransport([
keepAlive,
toProtoFlightData(generated.schemaFlightData, new Uint8Array(0)),
keepAlive,
toProtoFlightData(generated.recordBatchFlightData, recordBatchMetadata),
keepAlive
])
const layer = ArrowFlight.layer.pipe(Layer.provide(Layer.succeed(ArrowFlight.Transport, transport)))

const results = yield* Effect.gen(function* () {
const flight = yield* ArrowFlight.ArrowFlight
return yield* flight.query("SELECT id FROM test")
}).pipe(Effect.provide(layer))

expect(results).toHaveLength(1)
expect(results[0]?.data).toEqual(generated.expectedValues.id?.map((id) => ({ id })))
})
)
})
Loading