Skip to content

Commit 4306ad9

Browse files
committed
feat(pyspark): implement Distinct for pyspark
1 parent 3f48cb8 commit 4306ad9

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ibis/backends/pyspark/compiler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,12 @@ def compile_join(t, expr, scope, timecontext, *, how):
11761176
return left_df.join(right_df, pred_columns, how)
11771177

11781178

1179+
@compiles(ops.Distinct)
1180+
def compile_distinct(t, expr, scope, timecontext):
1181+
op = expr.op()
1182+
return t.translate(op.table, scope, timecontext).distinct()
1183+
1184+
11791185
def _canonicalize_interval(t, interval, scope, timecontext, **kwargs):
11801186
"""Convert interval to integer timestamp of second
11811187

ibis/tests/sql/test_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_table_distinct(con):
7171

7272
def test_column_distinct(con):
7373
t = con.table('functional_alltypes')
74-
expr = t[["string_col"]].distinct()
74+
expr = t[t.string_col].distinct()
7575

7676
result = Compiler.to_sql(expr)
7777
expected = """SELECT DISTINCT `string_col`

ibis/tests/sql/test_sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def test_not_exists(con, not_exists):
656656
).distinct(),
657657
),
658658
(
659-
lambda t: t[["string_col"]].distinct(),
659+
lambda t: t[t.string_col].distinct(),
660660
lambda sat: sa.select([sat.c.string_col.distinct()]),
661661
),
662662
(

0 commit comments

Comments
 (0)