Skip to content

Commit

Permalink
feat(pyspark): support Table.sample
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Oct 17, 2023
1 parent 09a7626 commit 6aa897e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ def compile_limit(t, op, **kwargs):
return df


@compiles(ops.Sample)
def compile_sample(t, op, **kwargs):
df = t.translate(op.table, **kwargs)
return df.sample(fraction=op.fraction, seed=op.seed)


@compiles(ops.And)
def compile_and(t, op, **kwargs):
return t.translate(op.left, **kwargs) & t.translate(op.right, **kwargs)
Expand Down
3 changes: 0 additions & 3 deletions ibis/backends/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,6 @@ def test_dynamic_table_slice_with_computed_offset(backend):
"flink",
"impala",
"polars",
"pyspark",
"snowflake",
]
)
Expand All @@ -1564,7 +1563,6 @@ def test_sample(backend):
"flink",
"impala",
"polars",
"pyspark",
"snowflake",
]
)
Expand All @@ -1588,7 +1586,6 @@ def test_sample_memtable(con, backend):
"oracle",
"polars",
"postgres",
"pyspark",
"snowflake",
"sqlite",
"trino",
Expand Down

0 comments on commit 6aa897e

Please sign in to comment.