alexowens90 commented on issue #49309:
URL: https://github.com/apache/arrow/issues/49309#issuecomment-4004232240

   Yes, I have a workaround to use `table.schema` like so:
   ```
           if table.num_rows == 0:
               pa_record_batches = [
                   pa.RecordBatch.from_arrays(
                       [chunked_array.chunk(0) for chunked_array in 
table.itercolumns()], schema=table.schema
                   )
               ]
           else:
               pa_record_batches = table.to_batches()
   ```
   I guess the unexepcted behaviour from my perspective was that the following 
could does not work:
   ```
   >>> import pyarrow as pa
   >>> table = pa.table({"col": pa.array([], pa.int64())})
   >>> new_table = pa.Table.from_batches(table.to_batches())
   Traceback (most recent call last):
     File "<python-input-4>", line 1, in <module>
       new_table = pa.Table.from_batches(batches)
     File "pyarrow/table.pxi", line 5032, in pyarrow.lib.Table.from_batches
   ValueError: Must pass schema, or at least one RecordBatch
   ```


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