[
https://issues.apache.org/jira/browse/ARROW-10045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17207790#comment-17207790
]
Adam Lippai commented on ARROW-10045:
-------------------------------------
This works:
Returning the correct bytes from Python
{code:python}
table = pa.Table.from_pandas(df)
batches = table.to_batches()
sink = pa.BufferOutputStream()
writer = pa.ipc.new_stream(sink, table.schema)
for batch in batches:
writer.write_batch(batch)
writer.close()
response_bytes = sink.getvalue().to_pybytes(){code}
Using it in JS:
{code:javascript}
const table = await
Table.from(fetch(("/the/endpoint/returning/response_bytes")));
const my_column = table.getColumn("my_column").toArray();
{code}
I wonder what's the correct way, to yield the bytes after each
batch/header/footer instead of writing it to a sink (making it a generator).
> Pandas -> PyArrow ->JS
> ----------------------
>
> Key: ARROW-10045
> URL: https://issues.apache.org/jira/browse/ARROW-10045
> Project: Apache Arrow
> Issue Type: Improvement
> Components: JavaScript
> Affects Versions: 1.0.1
> Reporter: Adam Lippai
> Assignee: Uwe Korn
> Priority: Major
>
> Does the JS Table reader work?
> I return pa.serialize(pa.Table.from_pandas(df)).to_buffer().to_pybytes() as
> application/octet-stream from a HTTP endpoint.
> Then using Javascript I try to read it:
> const table = await Table.from(fetch(("/myendpoint")));
> console.log(table.toString());
> but it prints only [object Object] and using the debugger shows an
> empty&unusable table. Schema and data is empty, the column with the given
> name is not found.
> It doesn't throw any error.
> How is this supposed to work? Do I miss something on the python or JS side?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)