Skip to content

Commit 1666e33

Browse files
mesejocpcloud
authored andcommitted
feat(datafusion): add BitwiseNot, Clip and IntervalFromInteger
1 parent 87bc514 commit 1666e33

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

ibis/backends/sql/compilers/datafusion.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ class DataFusionCompiler(SQLGlotCompiler):
3333
ops.ArrayFilter,
3434
ops.ArrayMap,
3535
ops.ArrayZip,
36-
ops.BitwiseNot,
37-
ops.Clip,
3836
ops.CountDistinctStar,
3937
ops.DateDelta,
40-
ops.IntervalFromInteger,
4138
ops.RowID,
4239
ops.Strftime,
4340
ops.TimeDelta,
@@ -599,11 +596,13 @@ def visit_ArrayAny(self, op, *, arg):
599596
),
600597
)
601598

602-
def visit_Greatest(self, op, *, arg):
603-
return self.f.greatest(*arg)
599+
def visit_BitwiseNot(self, op, *, arg):
600+
# https://stackoverflow.com/q/69648488/4001592
601+
return sge.BitwiseXor(this=arg, expression=sge.Literal.number(-1))
604602

605-
def visit_Least(self, op, *, arg):
606-
return self.f.least(*arg)
603+
def visit_IntervalFromInteger(self, op, *, arg, unit):
604+
unit = unit.name.lower()
605+
return sg.cast(self.f.concat(self.cast(arg, dt.string), f" {unit}"), "interval")
607606

608607

609608
compiler = DataFusionCompiler()

ibis/backends/tests/test_numeric.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,6 @@ def test_random_different_per_row(alltypes):
13621362
),
13631363
],
13641364
)
1365-
@pytest.mark.notimpl(["datafusion"], raises=com.OperationNotDefinedError)
13661365
def test_clip(backend, alltypes, df, ibis_func, pandas_func):
13671366
result = ibis_func(alltypes.int_col).execute()
13681367
expected = pandas_func(df.int_col).astype(result.dtype)
@@ -1371,7 +1370,7 @@ def test_clip(backend, alltypes, df, ibis_func, pandas_func):
13711370
backend.assert_series_equal(result, expected, check_names=False)
13721371

13731372

1374-
@pytest.mark.notimpl(["datafusion", "polars"], raises=com.OperationNotDefinedError)
1373+
@pytest.mark.notimpl(["polars"], raises=com.OperationNotDefinedError)
13751374
@pytest.mark.notyet(
13761375
["druid"],
13771376
raises=PyDruidProgrammingError,
@@ -1509,7 +1508,7 @@ def test_bitwise_scalars(con, op, left, right):
15091508
assert result == expected
15101509

15111510

1512-
@pytest.mark.notimpl(["datafusion", "exasol"], raises=com.OperationNotDefinedError)
1511+
@pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError)
15131512
@pytest.mark.notimpl(["oracle"], raises=OracleDatabaseError)
15141513
@flink_no_bitwise
15151514
def test_bitwise_not_scalar(con):
@@ -1519,7 +1518,7 @@ def test_bitwise_not_scalar(con):
15191518
assert result == expected
15201519

15211520

1522-
@pytest.mark.notimpl(["datafusion", "exasol"], raises=com.OperationNotDefinedError)
1521+
@pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError)
15231522
@pytest.mark.notimpl(["oracle"], raises=OracleDatabaseError)
15241523
@flink_no_bitwise
15251524
def test_bitwise_not_col(backend, alltypes, df):

ibis/backends/tests/test_temporal.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,7 @@ def test_date_truncate(backend, alltypes, df, unit):
552552
),
553553
],
554554
)
555-
@pytest.mark.notimpl(
556-
["datafusion", "druid", "exasol"], raises=com.OperationNotDefinedError
557-
)
555+
@pytest.mark.notimpl(["druid", "exasol"], raises=com.OperationNotDefinedError)
558556
def test_integer_to_interval_timestamp(
559557
backend, con, alltypes, df, unit, displacement_type
560558
):
@@ -628,7 +626,7 @@ def convert_to_offset(offset, displacement_type=displacement_type):
628626
param("D", marks=sqlite_without_ymd_intervals),
629627
],
630628
)
631-
@pytest.mark.notimpl(["datafusion", "druid"], raises=com.OperationNotDefinedError)
629+
@pytest.mark.notimpl(["druid"], raises=com.OperationNotDefinedError)
632630
@pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError)
633631
def test_integer_to_interval_date(backend, con, alltypes, df, unit):
634632
interval = alltypes.int_col.as_interval(unit)

0 commit comments

Comments
 (0)