romankarlstetter commented on issue #20196:
URL: https://github.com/apache/arrow/issues/20196#issuecomment-1691209159

   I tried to understand this a bit better.
   
   This error occured when reading a struct via arrow flight because the first 
argument `const flatbuf::RecordBatch* metadata` to the function 
`arrow::ipc::LoadRecordBatch()` only contained the toplevel nodes, while the 
[comment in the flatbuffer definition of the 
RecordBatch](https://github.com/apache/arrow/blob/apache-arrow-12.0.0/format/Message.fbs#L90)
 says that this should be the list flattened nodes.
   
   After digging a bit deeper, I understood that the problem I was seeing is 
caused by an improper creation of an empty record batch on the sender side. 
When using `arrow::RecordBatch::MakeEmpty()` instead of the broken logic 
implemented before, everything works as expected 
(`arrow::RecordBatch::MakeEmpty()` did not exist at the time this was initially 
developed, and a stupid hack was used instead).
   
   ### Improvement suggestion
   It would maybe be worth to add a sanity check when creating the 
`flatbuf::RecordBatch` in `MakeRecordBatch()` in 
[metadata_internal.cc](https://github.com/apache/arrow/blob/apache-arrow-12.0.0/cpp/src/arrow/ipc/metadata_internal.cc#L967C10).
   Ideally, this would already raise an error when the created 
`flatbuf::RecordBatch` is inconsistent.
   
   I'm a bit unsure where this validation would be best implemented; maybe 
somewhere 
[here](https://github.com/apache/arrow/blob/apache-arrow-12.0.0/cpp/src/arrow/ipc/writer.cc#L240)
 or 
[here](https://github.com/apache/arrow/blob/apache-arrow-12.0.0/cpp/src/arrow/ipc/writer.cc#L690C23)?
   
   
   
   


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