suremarc commented on code in PR #4797:
URL: https://github.com/apache/arrow-rs/pull/4797#discussion_r1319945754
##########
arrow-flight/src/sql/server.rs:
##########
@@ -688,9 +688,17 @@ where
async fn do_put(
&self,
- mut request: Request<Streaming<FlightData>>,
+ request: Request<Streaming<FlightData>>,
) -> Result<Response<Self::DoPutStream>, Status> {
- let cmd = request.get_mut().message().await?.unwrap();
+ // See issue #4658: https://github.com/apache/arrow-rs/issues/4658
+ // To dispatch to the correct `do_put` method, we cannot discard the
first message,
+ // as it may contain the Arrow schema, which the `do_put` handler may
need.
+ // To allow the first message to be reused by the `do_put` handler,
+ // we wrap this stream in a `Peekable` one, which allows us to peek at
+ // the first message without discarding it.
+ let mut request = request.map(futures::StreamExt::peekable);
Review Comment:
Yes, that is my understanding as well. Prior to this change, decoding a
flight stream inside one of the `do_put` methods would give you an error like
`Received RecordBatch prior to schema`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]