Skip to content

Commit

Permalink
fix(datafusion/exasol/mssql/orace): make concat with null value consi…
Browse files Browse the repository at this point in the history
…stent
  • Loading branch information
cpcloud committed Feb 11, 2024
1 parent 5121474 commit a51468d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ibis/backends/datafusion/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ def visit_IsInf(self, op, *, arg):
def visit_ArrayIndex(self, op, *, arg, index):
return self.f.array_element(arg, index + self.cast(index >= 0, op.index.dtype))

@visit_node.register(ops.StringConcat)
def visit_StringConcat(self, op, *, arg):
any_args_null = (a.is_(NULL) for a in arg)
return self.if_(sg.or_(*any_args_null), NULL, self.f.concat(*arg))

@visit_node.register(ops.Arbitrary)
@visit_node.register(ops.ArgMax)
@visit_node.register(ops.ArgMin)
Expand Down
6 changes: 6 additions & 0 deletions ibis/backends/exasol/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from functools import singledispatchmethod

import sqlglot as sg
import sqlglot.expressions as sge

import ibis.common.exceptions as com
Expand Down Expand Up @@ -101,6 +102,11 @@ def visit_StringContains(self, op, *, haystack, needle):
def visit_ExtractSecond(self, op, *, arg):
return self.f.floor(self.cast(self.f.extract(self.v.second, arg), op.dtype))

@visit_node.register(ops.StringConcat)
def visit_StringConcat(self, op, *, arg):
any_args_null = (a.is_(NULL) for a in arg)
return self.if_(sg.or_(*any_args_null), NULL, self.f.concat(*arg))

@visit_node.register(ops.AnalyticVectorizedUDF)
@visit_node.register(ops.ApproxMedian)
@visit_node.register(ops.Arbitrary)
Expand Down
5 changes: 5 additions & 0 deletions ibis/backends/mssql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ def visit_HexDigest(self, op, *, arg, how):
)
)

@visit_node.register(ops.StringConcat)
def visit_StringConcat(self, op, *, arg):
any_args_null = (a.is_(NULL) for a in arg)
return self.if_(sg.or_(*any_args_null), NULL, self.f.concat(*arg))

@visit_node.register(ops.Any)
@visit_node.register(ops.All)
@visit_node.register(ops.ApproxMedian)
Expand Down
5 changes: 5 additions & 0 deletions ibis/backends/oracle/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ def visit_Window(self, op, *, how, func, start, end, group_by, order_by):

return sge.Window(this=func, partition_by=group_by, order=order, spec=spec)

@visit_node.register(ops.StringConcat)
def visit_StringConcat(self, op, *, arg):
any_args_null = (a.is_(NULL) for a in arg)
return self.if_(sg.or_(*any_args_null), NULL, self.f.concat(*arg))

@visit_node.register(ops.Arbitrary)
@visit_node.register(ops.ArgMax)
@visit_node.register(ops.ArgMin)
Expand Down

0 comments on commit a51468d

Please sign in to comment.