MCPcopy Create free account
hub / github.com/apache/arrow-rs / execute_ingest

Method execute_ingest

arrow-flight/src/sql/client.rs:231–264  ·  view source on GitHub ↗

Execute a bulk ingest on the server and return the number of records added

(
        &mut self,
        command: CommandStatementIngest,
        stream: S,
    )

Source from the content-addressed store, hash-verified

229
230 /// Execute a bulk ingest on the server and return the number of records added
231 pub async fn execute_ingest<S>(
232 &mut self,
233 command: CommandStatementIngest,
234 stream: S,
235 ) -> Result<i64>
236 where
237 S: Stream<Item = crate::error::Result<RecordBatch>> + Send + 'static,
238 {
239 let (sender, receiver) = futures::channel::oneshot::channel();
240
241 let descriptor = FlightDescriptor::new_cmd(command.as_any().encode_to_vec());
242 let flight_data = FlightDataEncoderBuilder::new()
243 .with_flight_descriptor(Some(descriptor))
244 .build(stream);
245
246 // Intercept client errors and send them to the one shot channel above
247 let flight_data = Box::pin(flight_data);
248 let flight_data: FallibleRequestStream<FlightData, FlightError> =
249 FallibleRequestStream::new(sender, flight_data);
250
251 let req = self.set_request_headers(flight_data.into_streaming_request())?;
252 let mut result = self.flight_client.do_put(req).await?.into_inner();
253
254 // check if the there were any errors in the input stream provided note
255 // if receiver.await fails, it means the sender was dropped and there is
256 // no message to return.
257 if let Ok(msg) = receiver.await {
258 return Err(FlightError::ExternalError(Box::new(msg)));
259 }
260
261 let result = result.message().await?.unwrap();
262 let result: DoPutUpdateResult = Message::decode(&*result.app_metadata)?;
263 Ok(result.record_count)
264 }
265
266 /// Request a list of catalogs as tabular FlightInfo results
267 pub async fn get_catalogs(&mut self) -> Result<FlightInfo> {

Callers 2

test_execute_ingestFunction · 0.80

Calls 7

set_request_headersMethod · 0.80
decodeFunction · 0.50
as_anyMethod · 0.45
buildMethod · 0.45
into_innerMethod · 0.45
do_putMethod · 0.45

Tested by 2

test_execute_ingestFunction · 0.64