class NullIf(Value): """Set values to NULL if they equal the null_if_expr""" arg = rlz.any null_if_expr = rlz.any output_dtype = rlz.dtype_like("args") output_shape = rlz.shape_like("args")
class Clip(Value): arg = rlz.strict_numeric lower = rlz.optional(rlz.strict_numeric) upper = rlz.optional(rlz.strict_numeric) output_dtype = rlz.dtype_like("arg") output_shape = rlz.shape_like("args")
class ShiftBase(Analytic): arg = rlz.column(rlz.any) offset = rlz.optional(rlz.one_of((rlz.integer, rlz.interval))) default = rlz.optional(rlz.any) output_dtype = rlz.dtype_like("arg")
class ArraySlice(Value): arg = rlz.array start = rlz.integer stop = rlz.optional(rlz.integer) output_dtype = rlz.dtype_like("arg") output_shape = rlz.shape_like("arg")
class Conv_4326_900913_Y(ops.UnaryOp): """Converts WGS-84 longitude to WGS-84 Web Mercator y coordinate.""" if _ibis_legacy: output_type = rlz.shape_like('left', dt.float) else: output_dtype = rlz.dtype_like('left') output_shape = rlz.shape_like('left')
class NumericTruncate(ops.NumericBinaryOp): """Truncates x to y decimal places.""" if _ibis_legacy: output_type = rlz.shape_like('left', dt.float) else: output_dtype = rlz.dtype_like('left') output_shape = rlz.shape_like('left')
class ApproxMedian(Filterable, Reduction): """ Compute the approximate median of a set of comparable values using the Count-Min-Sketch algorithm. Exposed in Impala using APPX_MEDIAN. """ arg = rlz.column(rlz.any) output_dtype = rlz.dtype_like('arg')
class Alias(Value): arg = rlz.any name = rlz.instance_of((str, UnnamedMarker)) output_shape = rlz.shape_like("arg") output_dtype = rlz.dtype_like("arg") def has_resolved_name(self): return True def resolve_name(self): return self.name
class IfNull(Value): """ Equivalent to (but perhaps implemented differently): case().when(expr.notnull(), expr) .else_(null_substitute_expr) """ arg = rlz.any ifnull_expr = rlz.any output_dtype = rlz.dtype_like("args") output_shape = rlz.shape_like("args")
class ValueList(Value): """Data structure for a list of value expressions""" # NOTE: this proxies the Value behaviour to the underlying values values = rlz.tuple_of(rlz.any) output_type = ir.ValueList output_dtype = rlz.dtype_like("values") output_shape = rlz.shape_like("values") def root_tables(self): return distinct_roots(*self.values)
class BitXor(Filterable, Reduction): """Aggregate bitwise XOR operation. All elements in an integer column are XORed together. This can be used as a parity checksum of element values. Resources: * BigQuery [`BIT_XOR`](https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#bit_xor) * MySQL [`BIT_XOR`](https://dev.mysql.com/doc/refman/5.7/en/aggregate-functions.html#function_bit-xor) """ # noqa: E501 arg = rlz.column(rlz.integer) output_dtype = rlz.dtype_like('arg')
class BitOr(Filterable, Reduction): """Aggregate bitwise OR operation. All elements in an integer column are ORed together. This can be used to determine which bit flags are set on any element. Resources: * BigQuery [`BIT_OR`](https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#bit_or) * MySQL [`BIT_OR`](https://dev.mysql.com/doc/refman/5.7/en/aggregate-functions.html#function_bit-or) """ # noqa: E501 arg = rlz.column(rlz.integer) output_dtype = rlz.dtype_like('arg')
class Where(Value): """ Ternary case expression, equivalent to bool_expr.case() .when(True, true_expr) .else_(false_or_null_expr) """ bool_expr = rlz.boolean true_expr = rlz.any false_null_expr = rlz.any output_dtype = rlz.dtype_like("true_expr") output_shape = rlz.shape_like("bool_expr")
class ArrayConcat(Value): left = rlz.array right = rlz.array output_dtype = rlz.dtype_like("left") output_shape = rlz.shape_like("args") def __init__(self, left, right): left_dtype, right_dtype = left.type(), right.type() if left_dtype != right_dtype: raise com.IbisTypeError( 'Array types must match exactly in a {} operation. ' 'Left type {} != Right type {}'.format( type(self).__name__, left_dtype, right_dtype)) super().__init__(left=left, right=right)
class NullIfZero(Unary): """Set values to NULL if they are equal to zero. Commonly used in cases where divide-by-zero would produce an overflow or infinity. Equivalent to ```python (value == 0).ifelse(ibis.NA, value) ``` Returns ------- NumericValue The input if not zero otherwise `NULL`. """ arg = rlz.numeric output_dtype = rlz.dtype_like("arg")
class Window(Value): expr = rlz.analytic window = rlz.window(from_base_table_of="expr") output_dtype = rlz.dtype_like("expr") output_shape = rlz.Shape.COLUMNAR def __init__(self, expr, window): expr = propagate_down_window(expr, window) super().__init__(expr=expr, window=window) def over(self, window): new_window = self.window.combine(window) return Window(self.expr, new_window) @property def inputs(self): return self.expr.op().inputs[0], self.window def root_tables(self): return distinct_roots(self.expr, *self.window._order_by, *self.window._group_by)
class Min(Filterable, Reduction): arg = rlz.column(rlz.any) output_dtype = rlz.dtype_like('arg')
class TimestampSub(Binary): left = rlz.timestamp right = rlz.interval( units={'Y', 'Q', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns'} ) output_dtype = rlz.dtype_like('left')
class TimeSub(Binary): left = rlz.time right = rlz.interval(units={'h', 'm', 's', 'ms', 'us', 'ns'}) output_dtype = rlz.dtype_like('left')
class DateSub(Binary): left = rlz.date right = rlz.interval(units={'Y', 'Q', 'M', 'W', 'D'}) output_dtype = rlz.dtype_like('left')
class ZeroIfNull(Unary): output_dtype = rlz.dtype_like("arg")
class Negate(Unary): arg = rlz.one_of((rlz.numeric, rlz.interval)) output_dtype = rlz.dtype_like("arg")
class NthValue(Analytic): """Retrieve the Nth element.""" arg = rlz.column(rlz.any) nth = rlz.integer output_dtype = rlz.dtype_like("arg")
class CumulativeAll(CumulativeOp): arg = rlz.column(rlz.boolean) output_dtype = rlz.dtype_like("arg")
class CumulativeMin(CumulativeOp): """Cumulative min. Requires an order window.""" arg = rlz.column(rlz.any) output_dtype = rlz.dtype_like("arg")
class MapConcat(Value): left = rlz.mapping right = rlz.mapping output_shape = rlz.shape_like("args") output_dtype = rlz.dtype_like("args")
class Arbitrary(Filterable, Reduction): arg = rlz.column(rlz.any) how = rlz.optional(rlz.isin({'first', 'last', 'heavy'})) output_dtype = rlz.dtype_like('arg')
class Sign(Unary): arg = rlz.numeric output_dtype = rlz.dtype_like("arg")
class LastValue(Analytic): """Retrieve the last element.""" arg = rlz.column(rlz.any) output_dtype = rlz.dtype_like("arg")
class Abs(Unary): """Absolute value""" arg = rlz.numeric output_dtype = rlz.dtype_like("arg")