Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Perspective Table from empty Arrow Table #2844

Open
0x26res opened this issue Nov 11, 2024 · 0 comments
Open

Create Perspective Table from empty Arrow Table #2844

0x26res opened this issue Nov 11, 2024 · 0 comments

Comments

@0x26res
Copy link

0x26res commented Nov 11, 2024

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:

auto status3 = arrow::Table::FromRecordBatches(batches);

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"}).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant