예제 #1
0
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")
예제 #2
0
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")
예제 #3
0
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")
예제 #4
0
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")
예제 #5
0
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')
예제 #6
0
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')
예제 #7
0
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')
예제 #8
0
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
예제 #9
0
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")
예제 #10
0
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)
예제 #11
0
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')
예제 #12
0
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')
예제 #13
0
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")
예제 #14
0
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)
예제 #15
0
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")
예제 #16
0
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)
예제 #17
0
class Min(Filterable, Reduction):
    arg = rlz.column(rlz.any)
    output_dtype = rlz.dtype_like('arg')
예제 #18
0
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')
예제 #19
0
class TimeSub(Binary):
    left = rlz.time
    right = rlz.interval(units={'h', 'm', 's', 'ms', 'us', 'ns'})
    output_dtype = rlz.dtype_like('left')
예제 #20
0
class DateSub(Binary):
    left = rlz.date
    right = rlz.interval(units={'Y', 'Q', 'M', 'W', 'D'})
    output_dtype = rlz.dtype_like('left')
예제 #21
0
class ZeroIfNull(Unary):
    output_dtype = rlz.dtype_like("arg")
예제 #22
0
class Negate(Unary):
    arg = rlz.one_of((rlz.numeric, rlz.interval))

    output_dtype = rlz.dtype_like("arg")
예제 #23
0
class NthValue(Analytic):
    """Retrieve the Nth element."""

    arg = rlz.column(rlz.any)
    nth = rlz.integer
    output_dtype = rlz.dtype_like("arg")
예제 #24
0
class CumulativeAll(CumulativeOp):
    arg = rlz.column(rlz.boolean)
    output_dtype = rlz.dtype_like("arg")
예제 #25
0
class CumulativeMin(CumulativeOp):
    """Cumulative min. Requires an order window."""

    arg = rlz.column(rlz.any)
    output_dtype = rlz.dtype_like("arg")
예제 #26
0
파일: maps.py 프로젝트: ibis-project/ibis
class MapConcat(Value):
    left = rlz.mapping
    right = rlz.mapping

    output_shape = rlz.shape_like("args")
    output_dtype = rlz.dtype_like("args")
예제 #27
0
class Arbitrary(Filterable, Reduction):
    arg = rlz.column(rlz.any)
    how = rlz.optional(rlz.isin({'first', 'last', 'heavy'}))
    output_dtype = rlz.dtype_like('arg')
예제 #28
0
class Sign(Unary):
    arg = rlz.numeric
    output_dtype = rlz.dtype_like("arg")
예제 #29
0
class LastValue(Analytic):
    """Retrieve the last element."""

    arg = rlz.column(rlz.any)
    output_dtype = rlz.dtype_like("arg")
예제 #30
0
class Abs(Unary):
    """Absolute value"""

    arg = rlz.numeric
    output_dtype = rlz.dtype_like("arg")