Skip to content

Commit

Permalink
feat(pyarrow): support __arrow_c_schema__ on ibis.Schema objects (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist authored Jul 22, 2024
1 parent 310ad30 commit 00a776e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ibis/expr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def to_pyarrow(self):

return PyArrowSchema.from_ibis(self)

def __arrow_c_schema__(self):
return self.to_pyarrow().__arrow_c_schema__()

def to_polars(self):
"""Return the equivalent polars schema."""
from ibis.formats.polars import PolarsSchema
Expand Down
7 changes: 7 additions & 0 deletions ibis/expr/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,13 @@ def test_schema_from_to_pyarrow_schema():
assert restored_schema == pyarrow_schema


def test_schema___arrow_c_schema__():
pytest.importorskip("pyarrow")
schema = sch.Schema({"a": dt.int64, "b": dt.string, "c": dt.boolean})
# smoketest, since no way to create schema from capsule in current pyarrow
assert schema.__arrow_c_schema__() is not None


@pytest.mark.parametrize("lazy", [False, True])
def test_schema_infer_polars_dataframe(lazy):
pl = pytest.importorskip("polars")
Expand Down

0 comments on commit 00a776e

Please sign in to comment.