Skip to content

Commit

Permalink
feat(pandas): support passing memtables to create_table
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed May 24, 2023
1 parent b824142 commit 3ea9a21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ibis/backends/pandas/__init__.py
Expand Up @@ -179,6 +179,8 @@ def drop_table(self, name: str, *, force: bool = False) -> None:

@classmethod
def _supports_conversion(cls, obj: Any) -> bool:
if isinstance(obj, ir.Table):
return isinstance(obj.op(), ops.InMemoryTable)
return True

@staticmethod
Expand All @@ -187,6 +189,10 @@ def _from_pandas(df: pd.DataFrame) -> pd.DataFrame:

@classmethod
def _convert_object(cls, obj: Any) -> Any:
if isinstance(obj, ir.Table):
# Support memtables
assert isinstance(obj.op(), ops.InMemoryTable)
return obj.op().data.to_frame()
return cls.backend_table_type(obj)

@classmethod
Expand Down
2 changes: 0 additions & 2 deletions ibis/backends/tests/test_client.py
Expand Up @@ -745,12 +745,10 @@ def test_agg_memory_table(con):
[
param(
ibis.memtable([("a", 1.0)], columns=["a", "b"]),
marks=pytest.mark.notimpl(["pandas"]),
id="python",
),
param(
ibis.memtable(pd.DataFrame([("a", 1.0)], columns=["a", "b"])),
marks=pytest.mark.notimpl(["pandas"]),
id="pandas-memtable",
),
param(pd.DataFrame([("a", 1.0)], columns=["a", "b"]), id="pandas"),
Expand Down

0 comments on commit 3ea9a21

Please sign in to comment.