Skip to content

Commit

Permalink
fix(flink): fix 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 8f8843e commit 01117a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
6 changes: 5 additions & 1 deletion ibis/backends/sql/compilers/flink.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class FlinkCompiler(SQLGlotCompiler):
ops.StringLength: "char_length",
ops.StringToDate: "to_date",
ops.StringToTimestamp: "to_timestamp",
ops.Strip: "trim",
ops.TypeOf: "typeof",
}

Expand Down Expand Up @@ -589,5 +588,10 @@ def visit_ArrayCollect(self, op, *, arg, where, order_by, include_null):
out = sge.Filter(this=out, expression=sge.Where(this=where))
return out

def visit_Strip(self, op, *, arg):
# TODO: at some point, the upstream `BTRIM` function should work, but it
# currently doesn't, so we use a combination of left and right trim here
return self.visit_RStrip(op, arg=self.visit_LStrip(op, arg=arg))


compiler = FlinkCompiler()
11 changes: 0 additions & 11 deletions ibis/backends/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,17 +1297,6 @@ def string_temp_table(backend, con):
lambda t: t.string_col.strip(),
lambda t: t.str.strip(),
id="strip",
marks=[
pytest.mark.notimpl(
["flink"],
raises=AssertionError,
reason="""
Flink TRIM doesn't respect strip characters
but rstrip and lstrip work.
There's `BTRIM` but maybe only in dev?
""",
),
],
),
param(
lambda t: t.string_col.upper(),
Expand Down

0 comments on commit 01117a5

Please sign in to comment.