Skip to content

Commit

Permalink
feat(mssql): add startswith and endswith ops
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek authored and jcrist committed Sep 6, 2024
1 parent 37e4439 commit 17a628c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
8 changes: 6 additions & 2 deletions ibis/backends/sql/compilers/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class MSSQLCompiler(SQLGlotCompiler):
ops.Covariance,
ops.CountDistinctStar,
ops.DateDiff,
ops.EndsWith,
ops.IntervalAdd,
ops.IntervalSubtract,
ops.IntervalMultiply,
Expand All @@ -108,7 +107,6 @@ class MSSQLCompiler(SQLGlotCompiler):
ops.RegexSplit,
ops.RowID,
ops.RPad,
ops.StartsWith,
ops.StringSplit,
ops.StringToDate,
ops.StringToTimestamp,
Expand Down Expand Up @@ -522,5 +520,11 @@ def visit_TimestampSub(self, op, *, left, right):
visit_DateAdd = visit_TimestampAdd
visit_DateSub = visit_TimestampSub

def visit_StartsWith(self, op, *, arg, start):
return arg.like(self.f.concat(start, "%"))

def visit_EndsWith(self, op, *, arg, end):
return arg.like(self.f.concat("%", end))


compiler = MSSQLCompiler()
12 changes: 0 additions & 12 deletions ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,35 +515,23 @@ def uses_java_re(t):
),
lambda t: t.int_col == 1,
id="startswith",
marks=[
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
],
),
param(
lambda t: t.int_col.cases([(1, "abcd"), (2, "ABCD")], "dabc").endswith(
"bcd"
),
lambda t: t.int_col == 1,
id="endswith",
marks=[
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
],
),
param(
lambda t: t.date_string_col.startswith("2010-01"),
lambda t: t.date_string_col.str.startswith("2010-01"),
id="startswith-simple",
marks=[
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
],
),
param(
lambda t: t.date_string_col.endswith("/10"),
lambda t: t.date_string_col.str.endswith("/10"),
id="endswith-simple",
marks=[
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
],
),
param(
lambda t: t.string_col.strip(),
Expand Down

0 comments on commit 17a628c

Please sign in to comment.