Create Perspective Table from empty Arrow Table
Closed this issue · 1 comments
0x26res commented
Feature Request
Description of Problem:
I'm hosting arrow tables on a perspective server.
I get an error when I try to host empty tables. By empty table, I mean table with zero rows, but with columns and a well defined schema.
import pyarrow as pa
import perspective
perspective_server = perspective.Server()
client = perspective_server.new_local_client()
table = pa.table(
{
"col1": [1, 2, 3],
"col2": ["abc", "foo", "bar"],
}
)
empty_table = table.schema.empty_table()
client.table(table, name="table")
client.table(empty_table, name="table_empty_bad") # Throws an error
As a work around I have to explicitly pass the schema when the table is empty:
client.table({"col1": "integer", "col2": "string"}, name="table_empty_from_schema")
Potential Solutions:
I think it should be a simple change around this line:
As a side question, could you make available a util function to convert from pyarrow.Schema
to the perspective schema (eg: {"col1": "integer", "col2": "string"}
).