コード例 #1
0
ファイル: compiler.py プロジェクト: icexelloss/ibis
    ops.ExtractYear: _extract('year'),
    ops.ExtractMonth: _extract('month'),
    ops.ExtractDay: _extract('day'),
    ops.ExtractDayOfYear: unary('dayofyear'),
    ops.ExtractQuarter: _extract('quarter'),
    ops.ExtractEpochSeconds: unary('UNIX_TIMESTAMP'),
    ops.ExtractWeekOfYear: fixed_arity('weekofyear', 1),
    ops.ExtractHour: _extract('hour'),
    ops.ExtractMinute: _extract('minute'),
    ops.ExtractSecond: _extract('second'),
    ops.ExtractMillisecond: _extract('millisecond'),
    # reductions
    ops.BitAnd: _reduction(sa.func.bit_and),
    ops.BitOr: _reduction(sa.func.bit_or),
    ops.BitXor: _reduction(sa.func.bit_xor),
    ops.Variance: _variance_reduction('var'),
    ops.StandardDev: _variance_reduction('stddev'),
    ops.IdenticalTo: _identical_to,
    ops.TimestampNow: fixed_arity(sa.func.now, 0),
})


def add_operation(op, translation_func):
    _operation_registry[op] = translation_func


class MySQLExprTranslator(alch.AlchemyExprTranslator):

    _registry = _operation_registry
    _rewrites = alch.AlchemyExprTranslator._rewrites.copy()
    _type_map = alch.AlchemyExprTranslator._type_map.copy()
コード例 #2
0
ファイル: compiler.py プロジェクト: LeeTZ/ibis
        ops.StringAscii: unary(sa.func._ibis_sqlite_string_ascii),
        ops.Capitalize: unary(sa.func._ibis_sqlite_capitalize),
        ops.Translate: fixed_arity(sa.func._ibis_sqlite_translate, 3),
        ops.Sqrt: unary(sa.func._ibis_sqlite_sqrt),
        ops.Power: fixed_arity(sa.func._ibis_sqlite_power, 2),
        ops.Exp: unary(sa.func._ibis_sqlite_exp),
        ops.Ln: unary(sa.func._ibis_sqlite_ln),
        ops.Log: _log,
        ops.Log10: unary(sa.func._ibis_sqlite_log10),
        ops.Log2: unary(sa.func._ibis_sqlite_log2),
        ops.Floor: unary(sa.func._ibis_sqlite_floor),
        ops.Ceil: unary(sa.func._ibis_sqlite_ceil),
        ops.Sign: unary(sa.func._ibis_sqlite_sign),
        ops.FloorDivide: fixed_arity(sa.func._ibis_sqlite_floordiv, 2),
        ops.Modulus: fixed_arity(sa.func._ibis_sqlite_mod, 2),
        ops.Variance: _variance_reduction('_ibis_sqlite_var'),
        ops.StandardDev: toolz.compose(
            sa.func._ibis_sqlite_sqrt, _variance_reduction('_ibis_sqlite_var')
        ),
        ops.RowID: lambda t, expr: sa.literal_column('rowid'),
    }
)


def add_operation(op, translation_func):
    _operation_registry[op] = translation_func


class SQLiteExprTranslator(alch.AlchemyExprTranslator):

    _registry = _operation_registry
コード例 #3
0
ファイル: compiler.py プロジェクト: randxie/ibis
 ops.ExtractMillisecond:
 _millisecond,
 ops.DayOfWeekIndex:
 _day_of_week_index,
 ops.DayOfWeekName:
 _day_of_week_name,
 ops.Sum:
 _reduction('sum'),
 ops.Mean:
 _reduction('avg'),
 ops.Min:
 _reduction('min'),
 ops.Max:
 _reduction('max'),
 ops.Variance:
 _variance_reduction('var'),
 ops.StandardDev:
 _variance_reduction('stddev'),
 ops.RandomScalar:
 _random,
 # now is in the timezone of the server, but we want UTC
 ops.TimestampNow:
 lambda *args: sa.func.timezone('UTC', sa.func.now()),
 ops.CumulativeAll:
 unary(sa.func.bool_and),
 ops.CumulativeAny:
 unary(sa.func.bool_or),
 # array operations
 ops.ArrayLength:
 unary(_cardinality),
 ops.ArrayCollect:
コード例 #4
0
    ops.Log10:
    unary(sa.func._ibis_sqlite_log10),
    ops.Log2:
    unary(sa.func._ibis_sqlite_log2),
    ops.Floor:
    unary(sa.func._ibis_sqlite_floor),
    ops.Ceil:
    unary(sa.func._ibis_sqlite_ceil),
    ops.Sign:
    unary(sa.func._ibis_sqlite_sign),
    ops.FloorDivide:
    fixed_arity(sa.func._ibis_sqlite_floordiv, 2),
    ops.Modulus:
    fixed_arity(sa.func._ibis_sqlite_mod, 2),
    ops.Variance:
    _variance_reduction('_ibis_sqlite_var'),
    ops.StandardDev:
    toolz.compose(sa.func._ibis_sqlite_sqrt,
                  _variance_reduction('_ibis_sqlite_var')),
    ops.RowID:
    lambda t, expr: sa.literal_column('rowid'),
})


def add_operation(op, translation_func):
    _operation_registry[op] = translation_func


class SQLiteExprTranslator(alch.AlchemyExprTranslator):

    _registry = _operation_registry