27 changes: 7 additions & 20 deletions ibis/expr/operations/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ibis.common import exceptions as com
from ibis.common.annotations import attribute
from ibis.common.grounds import Singleton
from ibis.expr.operations.core import Named, Unary, Value
from ibis.expr.operations.core import Named, Unary, Value, Variadic
from ibis.util import frozendict

try:
Expand Down Expand Up @@ -155,31 +155,18 @@ class NullIf(Value):


@public
class CoalesceLike(Value):

# According to Impala documentation:
# Return type: same as the initial argument value, except that integer
# values are promoted to BIGINT and floating-point values are promoted to
# DOUBLE; use CAST() when inserting into a smaller numeric column
arg = rlz.nodes_of(rlz.any)

output_shape = rlz.shape_like('arg')
output_dtype = rlz.dtype_like('arg')


@public
class Coalesce(CoalesceLike):
pass
class Coalesce(Variadic):
arg = rlz.variadic(rlz.any)


@public
class Greatest(CoalesceLike):
pass
class Greatest(Variadic):
arg = rlz.variadic(rlz.any)


@public
class Least(CoalesceLike):
pass
class Least(Variadic):
arg = rlz.variadic(rlz.any)


@public
Expand Down
13 changes: 3 additions & 10 deletions ibis/expr/operations/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ibis.expr.datatypes as dt
import ibis.expr.rules as rlz
from ibis.common.annotations import attribute
from ibis.expr.operations.core import Unary, Value
from ibis.expr.operations.core import Unary, Value, Variadic


@public
Expand Down Expand Up @@ -216,15 +216,8 @@ class StringSplit(Value):


@public
class StringConcat(Value):
arg = rlz.nodes_of(rlz.string)

output_shape = rlz.shape_like("arg")
output_dtype = dt.string

@attribute.default
def output_shape(self):
return rlz.highest_precedence_shape(self.arg.values)
class StringConcat(Variadic):
arg = rlz.variadic(rlz.string)


@public
Expand Down
6 changes: 3 additions & 3 deletions ibis/expr/types/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def coalesce(self, *args: Value) -> Value:
>>> ibis.coalesce(None, 4, 5)
Coalesce([ValueList(values=[None, 4, 5])])
"""
return ops.Coalesce([self, *args]).to_expr()
return ops.Coalesce(self, *args).to_expr()

def greatest(self, *args: ir.Value) -> ir.Value:
"""Compute the largest value among the supplied arguments.
Expand All @@ -138,7 +138,7 @@ def greatest(self, *args: ir.Value) -> ir.Value:
Value
Maximum of the passed arguments
"""
return ops.Greatest([self, *args]).to_expr()
return ops.Greatest(self, *args).to_expr()

def least(self, *args: ir.Value) -> ir.Value:
"""Compute the smallest value among the supplied arguments.
Expand All @@ -153,7 +153,7 @@ def least(self, *args: ir.Value) -> ir.Value:
Value
Minimum of the passed arguments
"""
return ops.Least([self, *args]).to_expr()
return ops.Least(self, *args).to_expr()

def typeof(self) -> ir.StringValue:
"""Return the data type of the expression.
Expand Down
6 changes: 3 additions & 3 deletions ibis/expr/types/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def concat(
StringValue
All strings concatenated
"""
return ops.StringConcat([self, other, *args]).to_expr()
return ops.StringConcat(self, other, *args).to_expr()

def __add__(self, other: str | StringValue) -> StringValue:
"""Concatenate strings.
Expand All @@ -712,7 +712,7 @@ def __add__(self, other: str | StringValue) -> StringValue:
StringValue
All strings concatenated
"""
return ops.StringConcat([self, other]).to_expr()
return ops.StringConcat(self, other).to_expr()

def __radd__(self, other: str | StringValue) -> StringValue:
"""Concatenate strings.
Expand All @@ -727,7 +727,7 @@ def __radd__(self, other: str | StringValue) -> StringValue:
StringValue
All strings concatenated
"""
return ops.StringConcat([other, self]).to_expr()
return ops.StringConcat(other, self).to_expr()

def convert_base(
self,
Expand Down
2 changes: 1 addition & 1 deletion ibis/tests/expr/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
ops.RegexReplace('asd', 'as', 'a'),
ops.StringReplace('asd', 'as', 'a'),
ops.StringSplit('asd', 's'),
ops.StringConcat(['s', 'e']),
ops.StringConcat('s', 'e'),
ops.StartsWith('asd', 'as'),
ops.EndsWith('asd', 'xyz'),
ops.Not(false),
Expand Down