Skip to content

Commit

Permalink
feat(sqlite): implement bitwise xor and bitwise not
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Sep 5, 2022
1 parent 33cadb1 commit 58c42f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ibis/backends/sqlite/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,8 @@ def _time_from_hms(t, expr):
ops.Degrees: unary(sa.func._ibis_sqlite_degrees),
ops.Radians: unary(sa.func._ibis_sqlite_radians),
ops.Clip: _clip(min_func=sa.func.min, max_func=sa.func.max),
# sqlite doesn't implement a native xor operator
ops.BitwiseXor: fixed_arity(sa.func._ibis_sqlite_xor, 2),
ops.BitwiseNot: unary(sa.func._ibis_sqlite_inv),
}
)
10 changes: 10 additions & 0 deletions ibis/backends/sqlite/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ def _ibis_sqlite_radians(x):
return None if x is None else math.radians(x)


@udf
def _ibis_sqlite_xor(x, y):
return None if x is None or y is None else x ^ y


@udf
def _ibis_sqlite_inv(x):
return None if x is None else ~x


class _ibis_sqlite_var:
def __init__(self, offset):
self.mean = 0.0
Expand Down

0 comments on commit 58c42f9

Please sign in to comment.