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

depr(duckdb): deprecate read_in_memory #9666

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,12 @@ def _read_parquet_pyarrow_dataset(
# by the time we execute against this so we register it
# explicitly.

@util.deprecated(
instead="Pass in-memory data to `create_table` instead.",
as_of="9.1",
removed_in="10.0",
)
def read_in_memory(
# TODO: deprecate this in favor of `create_table`
self,
source: pd.DataFrame
| pa.Table
Expand Down
15 changes: 10 additions & 5 deletions ibis/backends/duckdb/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,13 @@
df_pandas_1 = pd.DataFrame({"a": ["a"], "b": [1], "d": ["hi"]})
df_pandas_2 = pd.DataFrame({"a": [1], "c": [1.4]})

table = con.read_in_memory(df_pandas_1, table_name="df")
with pytest.warns(FutureWarning, match="create_table"):
table = con.read_in_memory(df_pandas_1, table_name="df")

Check warning on line 325 in ibis/backends/duckdb/tests/test_register.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/duckdb/tests/test_register.py#L325

Added line #L325 was not covered by tests
assert len(table.columns) == 3
assert table.schema() == ibis.schema([("a", "str"), ("b", "int"), ("d", "str")])

table = con.read_in_memory(df_pandas_2, table_name="df")
with pytest.warns(FutureWarning, match="create_table"):
table = con.read_in_memory(df_pandas_2, table_name="df")

Check warning on line 330 in ibis/backends/duckdb/tests/test_register.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/duckdb/tests/test_register.py#L330

Added line #L330 was not covered by tests
assert len(table.columns) == 2
assert table.schema() == ibis.schema([("a", "int"), ("c", "float")])

Expand Down Expand Up @@ -415,7 +417,8 @@

def test_register_numpy_str(con):
data = pd.DataFrame({"a": [np.str_("xyz"), None]})
result = con.read_in_memory(data)
with pytest.warns(FutureWarning, match="create_table"):
result = con.read_in_memory(data)

Check warning on line 421 in ibis/backends/duckdb/tests/test_register.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/duckdb/tests/test_register.py#L421

Added line #L421 was not covered by tests
tm.assert_frame_equal(result.execute(), data)


Expand All @@ -428,7 +431,8 @@
)
reader = table.to_reader()
sol = table.to_pandas()
t = con.read_in_memory(reader)
with pytest.warns(FutureWarning, match="create_table"):
t = con.read_in_memory(reader)

Check warning on line 435 in ibis/backends/duckdb/tests/test_register.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/duckdb/tests/test_register.py#L435

Added line #L435 was not covered by tests

# First execute is fine
res = t.execute()
Expand All @@ -440,7 +444,8 @@

# Re-registering over the name with a new reader is fine
reader = table.to_reader()
t = con.read_in_memory(reader, table_name=t.get_name())
with pytest.warns(FutureWarning, match="create_table"):
t = con.read_in_memory(reader, table_name=t.get_name())

Check warning on line 448 in ibis/backends/duckdb/tests/test_register.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/duckdb/tests/test_register.py#L448

Added line #L448 was not covered by tests
res = t.execute()
tm.assert_frame_equal(res, sol)

Expand Down
8 changes: 6 additions & 2 deletions ibis/backends/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ def test_register_iterator_parquet(
assert table.count().execute()


# TODO: modify test to use read_in_memory when implemented xref: 8858
# TODO: remove entirely when `register` is removed
# This same functionality is implemented across all backends
# via `create_table` and tested in `test_client.py`
@pytest.mark.notimpl(["datafusion"])
@pytest.mark.notyet(
[
Expand Down Expand Up @@ -311,7 +313,9 @@ def test_register_pandas(con):
assert t.x.sum().execute() == 6


# TODO: modify test to use read_in_memory when implemented xref: 8858
# TODO: remove entirely when `register` is removed
# This same functionality is implemented across all backends
# via `create_table` and tested in `test_client.py`
@pytest.mark.notimpl(["datafusion", "polars"])
@pytest.mark.notyet(
[
Expand Down