Skip to content

Commit

Permalink
test(create_table): use lambdas for all inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth committed May 28, 2024
1 parent a1d9227 commit 1bfbdb8
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,9 @@ def test_self_join_memory_table(backend, con, monkeypatch):
@pytest.mark.parametrize(
"obj, table_name",
[
param(pa.table({"a": ["a"], "b": [1]}), "df_arrow", id="pyarrow table"),
param(lambda: pa.table({"a": ["a"], "b": [1]}), "df_arrow", id="pyarrow table"),
param(
pa.table({"a": ["a"], "b": [1]}).to_reader(),
lambda: pa.table({"a": ["a"], "b": [1]}).to_reader(),
"df_arrow_batch_reader",
marks=[
pytest.mark.notimpl(
Expand All @@ -916,7 +916,7 @@ def test_self_join_memory_table(backend, con, monkeypatch):
id="pyarrow_rbr",
),
param(
pa.table({"a": ["a"], "b": [1]}).to_batches()[0],
lambda: pa.table({"a": ["a"], "b": [1]}).to_batches()[0],
"df_arrow_single_batch",
marks=[
pytest.mark.notimpl(
Expand All @@ -943,7 +943,7 @@ def test_self_join_memory_table(backend, con, monkeypatch):
id="pyarrow_single_batch",
),
param(
pa.dataset.dataset(pa.table({"a": ["a"], "b": [1]})),
lambda: pa.dataset.dataset(pa.table({"a": ["a"], "b": [1]})),
"df_arrow_dataset",
marks=[
pytest.mark.notimpl(
Expand All @@ -970,40 +970,17 @@ def test_self_join_memory_table(backend, con, monkeypatch):
],
id="pyarrow dataset",
),
param(pd.DataFrame({"a": ["a"], "b": [1]}), "df_pandas", id="pandas"),
param(lambda: pd.DataFrame({"a": ["a"], "b": [1]}), "df_pandas", id="pandas"),
param(
pl.DataFrame({"a": ["a"], "b": [1]}),
lambda: pl.DataFrame({"a": ["a"], "b": [1]}),
"df_polars_eager",
id="polars dataframe",
),
param(
pl.LazyFrame({"a": ["a"], "b": [1]}),
lambda: pl.LazyFrame({"a": ["a"], "b": [1]}),
"df_polars_lazy",
id="polars lazyframe",
),
],
)
@pytest.mark.notimpl(["druid"])
@pytest.mark.notimpl(
["flink"],
reason="Flink backend supports creating only TEMPORARY VIEW for in-memory data.",
)
def test_create_table_in_memory(con, obj, table_name):
t = con.create_table(table_name, obj)

result = pa.table({"a": ["a"], "b": [1]})
assert table_name in con.list_tables()

assert result.equals(t.to_pyarrow())

with contextlib.suppress(NotImplementedError):
# polars doesn't have drop_table
con.drop_table(table_name, force=True)


@pytest.mark.parametrize(
"obj, table_name",
[
param(
lambda: ibis.memtable([("a", 1)], columns=["a", "b"]),
"memtable",
Expand Down Expand Up @@ -1031,11 +1008,14 @@ def test_create_table_in_memory(con, obj, table_name):
),
],
)
def test_create_table_from_memtable(con, obj, table_name, monkeypatch):
@pytest.mark.notimpl(["druid"])
@pytest.mark.notimpl(
["flink"],
reason="Flink backend supports creating only TEMPORARY VIEW for in-memory data.",
)
def test_create_table_in_memory(con, obj, table_name, monkeypatch):
monkeypatch.setattr(ibis.options, "default_backend", con)

obj = obj()

t = con.create_table(table_name, obj)

result = pa.table({"a": ["a"], "b": [1]})
Expand Down

0 comments on commit 1bfbdb8

Please sign in to comment.