ShivamSharma43 commented on code in PR #1549:
URL: https://github.com/apache/arrow-go/pull/1549#discussion_r4657806968


##########
arrow/flight/record_batch_reader.go:
##########
@@ -56,28 +56,37 @@ func (d *dataMessageReader) Message() (*ipc.Message, error) 
{
                err error
        )
 
-       if d.peeked != nil {
-               fd = d.peeked
-               d.peeked = nil
-       } else {
-               fd, err = d.rdr.Recv()
-       }
+       for {
+               if d.peeked != nil {
+                       fd = d.peeked
+                       d.peeked = nil
+               } else {
+                       fd, err = d.rdr.Recv()
+               }
 
-       if err != nil {
-               if d.msg != nil {
-                       // clear the previous message in the error case
-                       d.msg.Release()
-                       d.msg = nil
+               if err != nil {
+                       if d.msg != nil {
+                               // clear the previous message in the error case
+                               d.msg.Release()
+                               d.msg = nil
+                       }
+                       d.lastAppMetadata = nil
+                       d.descr = nil
+                       return nil, err
+               }
+
+               if fd.FlightDescriptor != nil {
+                       d.descr = fd.FlightDescriptor
+               }
+               // a message with neither an IPC header nor a body only carries
+               // app metadata (see Writer.WriteMetadata); there is no IPC 
message
+               // to decode, so skip it
+               if len(fd.DataHeader) > 0 || len(fd.DataBody) > 0 {

Review Comment:
   Done in fde223b: a message with a body but no header now fails with 
"arrow/flight: FlightData has a body but no IPC header", with a test for the 
mid-stream case (on the previous commit it fails with the index out of range 
error). Such a message as the very first one is still dropped by the descriptor 
peek in `NewRecordReader`, as on main. I also added the doc sentence to 
`Reader` about skipped metadata-only messages.



-- 
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]

Reply via email to