Skip to content

Commit

Permalink
feat(datafusion): implement arbitrary
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Mar 29, 2024
1 parent b514c23 commit 43a8f50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ibis/backends/datafusion/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class DataFusionCompiler(SQLGlotCompiler):
)

SIMPLE_OPS = {
ops.Arbitrary: "first_value",
ops.ApproxMedian: "approx_median",
ops.ArrayRemove: "array_remove_all",
ops.BitAnd: "bit_and",
Expand Down Expand Up @@ -152,6 +151,12 @@ def visit_Substring(self, op, *, arg, start, length):
return self.f.substr(arg, start, length)
return self.f.substr(arg, start)

def visit_Arbitrary(self, op, *, arg, where):
cond = ~arg.is_(None)
if where is not None:
cond &= where
return self.agg.first_value(arg, where=cond)

def visit_Variance(self, op, *, arg, how, where):
if how == "sample":
return self.agg.var_samp(arg, where=where)
Expand Down
1 change: 0 additions & 1 deletion ibis/backends/tests/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ def test_reduction_ops(
"impala",
"mysql",
"polars",
"datafusion",
"mssql",
"druid",
"oracle",
Expand Down

0 comments on commit 43a8f50

Please sign in to comment.