Skip to content

Commit

Permalink
feat(pyspark): implement Intersection and Difference
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 29, 2022
1 parent 2bc0b69 commit 9845a3c
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ibis/backends/pyspark/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,28 @@ def compile_aggregation(t, expr, scope, timecontext, **kwargs):
@compiles(ops.Union)
def compile_union(t, expr, scope, timecontext, **kwargs):
op = expr.op()
result = t.translate(op.left, scope, timecontext).union(
t.translate(op.right, scope, timecontext)
)
left = t.translate(op.left, scope, timecontext, **kwargs)
right = t.translate(op.right, scope, timecontext, **kwargs)
result = left.union(right)
return result.distinct() if op.distinct else result


@compiles(ops.Intersection)
def compile_intersection(t, expr, scope, timecontext, **kwargs):
op = expr.op()
left = t.translate(op.left, scope, timecontext, **kwargs)
right = t.translate(op.right, scope, timecontext, **kwargs)
return left.intersect(right) if op.distinct else left.intersectAll(right)


@compiles(ops.Difference)
def compile_difference(t, expr, scope, timecontext, **kwargs):
op = expr.op()
left = t.translate(op.left, scope, timecontext, **kwargs)
right = t.translate(op.right, scope, timecontext, **kwargs)
return left.subtract(right) if op.distinct else left.exceptAll(right)


@compiles(ops.Contains)
def compile_contains(t, expr, scope, timecontext, **kwargs):
op = expr.op()
Expand Down

0 comments on commit 9845a3c

Please sign in to comment.