Skip to content

Commit

Permalink
test(snowflake): enable passing row-wise sampling on views
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed May 6, 2024
1 parent 361fedc commit 6bd9e12
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions ibis/backends/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,27 +1924,34 @@ def test_dynamic_table_slice_with_computed_offset(backend):


@pytest.mark.notimpl(["druid", "polars"])
@pytest.mark.notimpl(
["snowflake"],
raises=SnowflakeProgrammingError,
reason="SAMPLE clause on views only supports row wise sampling without seed.",
)
@pytest.mark.notimpl(
["risingwave"],
raises=PsycoPg2InternalError,
reason="function random() does not exist",
)
def test_sample(backend):
@pytest.mark.parametrize(
"method",
[
"row",
param(
"block",
marks=[
pytest.mark.notimpl(
["snowflake"],
raises=SnowflakeProgrammingError,
reason="SAMPLE clause on views only supports row wise sampling without seed.",
)
],
),
],
)
def test_sample(backend, method):
t = backend.functional_alltypes.filter(_.int_col >= 2)

total_rows = t.count().execute()
empty = t.limit(1).execute().iloc[:0]

df = t.sample(0.1, method="row").execute()
assert len(df) <= total_rows
backend.assert_frame_equal(empty, df.iloc[:0])

df = t.sample(0.1, method="block").execute()
df = t.sample(0.1, method=method).execute()
assert len(df) <= total_rows
backend.assert_frame_equal(empty, df.iloc[:0])

Expand Down

0 comments on commit 6bd9e12

Please sign in to comment.