Skip to content

Commit 10aa7d7

Browse files
mesejocpcloud
authored andcommitted
feat(datafusion): add Greatest and Least
1 parent 969453e commit 10aa7d7

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

ibis/backends/sql/compilers/datafusion.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class DataFusionCompiler(SQLGlotCompiler):
3737
ops.Clip,
3838
ops.CountDistinctStar,
3939
ops.DateDelta,
40-
ops.Greatest,
4140
ops.IntervalFromInteger,
42-
ops.Least,
4341
ops.RowID,
4442
ops.Strftime,
4543
ops.TimeDelta,
@@ -601,5 +599,11 @@ def visit_ArrayAny(self, op, *, arg):
601599
),
602600
)
603601

602+
def visit_Greatest(self, op, *, arg):
603+
return self.f.greatest(*arg)
604+
605+
def visit_Least(self, op, *, arg):
606+
return self.f.least(*arg)
607+
604608

605609
compiler = DataFusionCompiler()

ibis/backends/tests/test_numeric.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -755,17 +755,11 @@ def test_isnan_isinf(
755755
ibis.least(L(10), L(1)),
756756
1,
757757
id="least",
758-
marks=pytest.mark.notimpl(
759-
["datafusion"], raises=com.OperationNotDefinedError
760-
),
761758
),
762759
param(
763760
ibis.greatest(L(10), L(1)),
764761
10,
765762
id="greatest",
766-
marks=pytest.mark.notimpl(
767-
["datafusion"], raises=com.OperationNotDefinedError
768-
),
769763
),
770764
param(L(5.5).round(), 6.0, id="round"),
771765
param(L(5.556).round(2), 5.56, id="round-digits"),
@@ -1043,14 +1037,6 @@ def test_floor_divide_precedence(con):
10431037
),
10441038
id="log_base_bigint",
10451039
marks=[
1046-
pytest.mark.notimpl(
1047-
["datafusion"], raises=com.OperationNotDefinedError
1048-
),
1049-
pytest.mark.notimpl(
1050-
["datafusion"],
1051-
raises=ValueError,
1052-
reason="Base greatest(9000, t0.bigint_col) for logarithm not supported!",
1053-
),
10541040
pytest.mark.notimpl(["polars"], raises=com.UnsupportedArgumentError),
10551041
pytest.mark.notimpl(
10561042
["risingwave"],
@@ -1100,37 +1086,25 @@ def test_complex_math_functions_columns(
11001086
lambda be, t: ibis.least(t.bigint_col, t.int_col),
11011087
lambda be, t: pd.Series(list(map(min, t.bigint_col, t.int_col))),
11021088
id="least-all-columns",
1103-
marks=pytest.mark.notimpl(
1104-
["datafusion"], raises=com.OperationNotDefinedError
1105-
),
11061089
),
11071090
param(
11081091
lambda be, t: ibis.least(t.bigint_col, t.int_col, -2),
11091092
lambda be, t: pd.Series(
11101093
list(map(min, t.bigint_col, t.int_col, [-2] * len(t)))
11111094
),
11121095
id="least-scalar",
1113-
marks=pytest.mark.notimpl(
1114-
["datafusion"], raises=com.OperationNotDefinedError
1115-
),
11161096
),
11171097
param(
11181098
lambda be, t: ibis.greatest(t.bigint_col, t.int_col),
11191099
lambda be, t: pd.Series(list(map(max, t.bigint_col, t.int_col))),
11201100
id="greatest-all-columns",
1121-
marks=pytest.mark.notimpl(
1122-
["datafusion"], raises=com.OperationNotDefinedError
1123-
),
11241101
),
11251102
param(
11261103
lambda be, t: ibis.greatest(t.bigint_col, t.int_col, -2),
11271104
lambda be, t: pd.Series(
11281105
list(map(max, t.bigint_col, t.int_col, [-2] * len(t)))
11291106
),
11301107
id="greatest-scalar",
1131-
marks=pytest.mark.notimpl(
1132-
["datafusion"], raises=com.OperationNotDefinedError
1133-
),
11341108
),
11351109
],
11361110
)

0 commit comments

Comments
 (0)