Skip to content

Commit

Permalink
fix(oracle): fix lstrip, rstrip, and strip
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth authored and cpcloud committed Sep 6, 2024
1 parent d2539c4 commit 3f5a304
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
13 changes: 5 additions & 8 deletions ibis/backends/sql/compilers/oracle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import string

import sqlglot as sg
import sqlglot.expressions as sge
import toolz
Expand Down Expand Up @@ -87,7 +85,6 @@ class OracleCompiler(SQLGlotCompiler):
ops.LPad: "lpad",
ops.RPad: "rpad",
ops.StringAscii: "ascii",
ops.Strip: "trim",
ops.Mode: "stats_mode",
}

Expand Down Expand Up @@ -492,11 +489,11 @@ def visit_DateDelta(self, op, *, left, right, part):
)
return left - right

def visit_RStrip(self, op, *, arg):
return self.f.anon.rtrim(arg, string.whitespace)

def visit_LStrip(self, op, *, arg):
return self.f.anon.ltrim(arg, string.whitespace)
def visit_Strip(self, op, *, arg):
# Oracle's `TRIM` only accepts a single character to trim off, unlike
# Oracle's `RTRIM` and `LTRIM` which accept a set of characters to
# remove.
return self.visit_RStrip(op, arg=self.visit_LStrip(op, arg=arg))


compiler = OracleCompiler()
8 changes: 0 additions & 8 deletions ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,14 +1308,6 @@ def string_temp_table(backend, con):
TRIM(LEADING '\t\n\r ' FROM string_col)
""",
),
pytest.mark.notimpl(
["oracle"],
raises=AssertionError,
reason="""
Oracle `trim` doesn't accept characters to trim
(unlike oracle `rtrim` and `ltrim`)
""",
),
pytest.mark.notimpl(
["flink"],
raises=AssertionError,
Expand Down

0 comments on commit 3f5a304

Please sign in to comment.