Skip to content

Create Perspective Table from empty Arrow Table #2844

@0x26res

Description

@0x26res

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: https://github.com/finos/perspective/blob/452bfb0eb0287bbd32814ec3ddc40128ba8b3bde/cpp/perspective/src/cpp/arrow_loader.cpp#L94

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions