Streaming
The @spiceai/spice
SDK supports streaming partial results as they become available.
This can be used to enable more efficient pipelining scenarios where processing each row of the result set can happen independently.
The Client.query
function takes an optional onData
callback that will be passed partial results as they become available.
In this example, we retrieve all 10,000 suppliers from the TPCH Suppliers table. This query retrieves all suppliers in a single call:
This call will wait for the promise returned by query()
to complete, returning all 10,000 suppliers.
Alternatively, data can be processed as it is streamed to the SDK. Provide a callback function to the onData
parameter, which will be called with every partial set of data streamed to the SDK:
Last updated