Skip to content

Commit 17a628c

Browse files
IndexSeekjcrist
authored andcommitted
feat(mssql): add startswith and endswith ops
1 parent 37e4439 commit 17a628c

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

ibis/backends/sql/compilers/mssql.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class MSSQLCompiler(SQLGlotCompiler):
8989
ops.Covariance,
9090
ops.CountDistinctStar,
9191
ops.DateDiff,
92-
ops.EndsWith,
9392
ops.IntervalAdd,
9493
ops.IntervalSubtract,
9594
ops.IntervalMultiply,
@@ -108,7 +107,6 @@ class MSSQLCompiler(SQLGlotCompiler):
108107
ops.RegexSplit,
109108
ops.RowID,
110109
ops.RPad,
111-
ops.StartsWith,
112110
ops.StringSplit,
113111
ops.StringToDate,
114112
ops.StringToTimestamp,
@@ -522,5 +520,11 @@ def visit_TimestampSub(self, op, *, left, right):
522520
visit_DateAdd = visit_TimestampAdd
523521
visit_DateSub = visit_TimestampSub
524522

523+
def visit_StartsWith(self, op, *, arg, start):
524+
return arg.like(self.f.concat(start, "%"))
525+
526+
def visit_EndsWith(self, op, *, arg, end):
527+
return arg.like(self.f.concat("%", end))
528+
525529

526530
compiler = MSSQLCompiler()

ibis/backends/tests/test_string.py

-12
Original file line numberDiff line numberDiff line change
@@ -515,35 +515,23 @@ def uses_java_re(t):
515515
),
516516
lambda t: t.int_col == 1,
517517
id="startswith",
518-
marks=[
519-
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
520-
],
521518
),
522519
param(
523520
lambda t: t.int_col.cases([(1, "abcd"), (2, "ABCD")], "dabc").endswith(
524521
"bcd"
525522
),
526523
lambda t: t.int_col == 1,
527524
id="endswith",
528-
marks=[
529-
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
530-
],
531525
),
532526
param(
533527
lambda t: t.date_string_col.startswith("2010-01"),
534528
lambda t: t.date_string_col.str.startswith("2010-01"),
535529
id="startswith-simple",
536-
marks=[
537-
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
538-
],
539530
),
540531
param(
541532
lambda t: t.date_string_col.endswith("/10"),
542533
lambda t: t.date_string_col.str.endswith("/10"),
543534
id="endswith-simple",
544-
marks=[
545-
pytest.mark.notimpl(["mssql"], raises=com.OperationNotDefinedError),
546-
],
547535
),
548536
param(
549537
lambda t: t.string_col.strip(),

0 commit comments

Comments
 (0)