ops.Least: varargs(sa.func.min), ops.Greatest: varargs(sa.func.max), ops.IfNull: fixed_arity(sa.func.ifnull, 2), ops.DateFromYMD: _date_from_ymd, ops.TimeFromHMS: _time_from_hms, ops.TimestampFromYMDHMS: _timestamp_from_ymdhms, ops.DateTruncate: _truncate(sa.func.date), ops.Date: unary(sa.func.date), ops.TimestampTruncate: _truncate(sa.func.datetime), ops.Strftime: _strftime, ops.ExtractYear: _strftime_int('%Y'), ops.ExtractMonth: _strftime_int('%m'), ops.ExtractDay: _strftime_int('%d'), ops.ExtractWeekOfYear: _extract_week_of_year, ops.ExtractDayOfYear: _strftime_int('%j'), ops.ExtractQuarter:
- 1 ) operation_registry.update( { ops.Literal: _literal, ops.IfNull: fixed_arity(sa.func.ifnull, 2), # strings ops.StringFind: _gen_string_find(sa.func.locate), ops.FindInSet: _find_in_set, ops.Capitalize: _capitalize, ops.RegexSearch: fixed_arity(lambda x, y: x.op('REGEXP')(y), 2), # math ops.Log: _log, ops.Log2: unary(sa.func.log2), ops.Log10: unary(sa.func.log10), ops.Round: _round, # dates and times ops.DateAdd: fixed_arity(operator.add, 2), ops.DateSub: fixed_arity(operator.sub, 2), ops.DateDiff: fixed_arity(sa.func.datediff, 2), ops.TimestampAdd: fixed_arity(operator.add, 2), ops.TimestampSub: fixed_arity(operator.sub, 2), ops.TimestampDiff: _timestamp_diff, ops.DateTruncate: _truncate, ops.TimestampTruncate: _truncate, ops.IntervalFromInteger: _interval_from_integer, ops.Strftime: fixed_arity(sa.func.date_format, 2), ops.ExtractYear: _extract('year'), ops.ExtractMonth: _extract('month'),
str((index + 1).compile(compile_kwargs=dict(literal_binds=True)))), ), )], else_="", ) return result operation_registry.update({ ops.ArrayColumn: _array_column, ops.ArrayConcat: fixed_arity('array_concat', 2), ops.DayOfWeekName: unary(sa.func.dayname), ops.Literal: _literal, ops.Log2: unary(sa.func.log2), ops.Ln: unary(sa.func.ln), ops.Log: _log, # TODO: map operations, but DuckDB's maps are multimaps ops.Modulus: fixed_arity(operator.mod, 2), ops.Round: _round, ops.StructField: _struct_field,
ops.TableColumn: _table_column, # types ops.TypeOf: _typeof, # Floating ops.IsNan: _is_nan, ops.IsInf: _is_inf, # null handling ops.IfNull: fixed_arity(sa.func.coalesce, 2), # boolean reductions ops.Any: unary(sa.func.bool_or), ops.All: unary(sa.func.bool_and), ops.NotAny: unary(lambda x: sa.not_(sa.func.bool_or(x))), ops.NotAll: unary(lambda x: sa.not_(sa.func.bool_and(x))), # strings ops.GroupConcat: _string_agg, ops.Capitalize: unary(sa.func.initcap), ops.RegexSearch: fixed_arity(lambda x, y: x.op("~")(y), 2), ops.RegexReplace: _regex_replace,
ops.IdenticalTo: _identical_to, ops.RegexSearch: fixed_arity(sa.func._ibis_sqlite_regex_search, 2), ops.RegexReplace: fixed_arity(sa.func._ibis_sqlite_regex_replace, 3), ops.RegexExtract: fixed_arity(sa.func._ibis_sqlite_regex_extract, 3), ops.LPad: _lpad, ops.RPad: _rpad, ops.Repeat: _repeat, ops.Reverse: unary(sa.func._ibis_sqlite_reverse), 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:
def _day_of_week_name(t, expr): (arg, ) = expr.op().args return sa.func.dayname(t.translate(arg)) operation_registry.update({ ops.Literal: _literal, ops.IfNull: fixed_arity(sa.func.ifnull, 2), # strings ops.Substring: _substr, ops.StringFind: _string_find, ops.Capitalize: _capitalize, ops.RegexSearch: infix_op('REGEXP'), # math ops.Log: _log, ops.Log2: unary(sa.func.log2), ops.Log10: unary(sa.func.log10), ops.Round: _round, ops.RandomScalar: _random, # dates and times ops.Date: unary(sa.func.date), ops.DateAdd: infix_op('+'), ops.DateSub: infix_op('-'), ops.DateDiff: fixed_arity(sa.func.datediff, 2), ops.TimestampAdd: infix_op('+'), ops.TimestampSub: infix_op('-'), ops.TimestampDiff: _timestamp_diff, ops.DateTruncate: _truncate, ops.TimestampTruncate: _truncate, ops.IntervalFromInteger: _interval_from_integer, ops.Strftime: fixed_arity(sa.func.date_format, 2),
operation_registry.update( { ops.Literal: _literal, # We override this here to support time zones ops.TableColumn: _table_column, # types ops.Cast: _cast, ops.TypeOf: _typeof, # Floating ops.IsNan: _is_nan, ops.IsInf: _is_inf, # null handling ops.IfNull: fixed_arity(sa.func.coalesce, 2), # boolean reductions ops.Any: unary(sa.func.bool_or), ops.All: unary(sa.func.bool_and), ops.NotAny: unary(lambda x: sa.not_(sa.func.bool_or(x))), ops.NotAll: unary(lambda x: sa.not_(sa.func.bool_and(x))), # strings ops.Substring: _substr, ops.StringFind: _string_find, ops.GroupConcat: _string_agg, ops.Capitalize: unary(sa.func.initcap), ops.RegexSearch: infix_op('~'), ops.RegexReplace: _regex_replace, ops.Translate: fixed_arity('translate', 3), ops.RegexExtract: _regex_extract_, ops.StringSplit: fixed_arity(sa.func.string_to_array, 2), ops.StringJoin: _string_join, ops.FindInSet: _find_in_set,
ops.ExtractDayOfYear: _strftime_int('%j'), ops.ExtractQuarter: _extract_quarter, ops.ExtractEpochSeconds: _extract_epoch_seconds, ops.ExtractHour: _strftime_int('%H'), ops.ExtractMinute: _strftime_int('%M'), ops.ExtractSecond: _strftime_int('%S'), ops.ExtractMillisecond: _millisecond, ops.TimestampNow: _now, ops.IdenticalTo: _identical_to, ops.RegexSearch: fixed_arity(sa.func._ibis_sqlite_regex_search, 2), ops.RegexReplace: fixed_arity(sa.func._ibis_sqlite_regex_replace, 3), ops.RegexExtract: fixed_arity(sa.func._ibis_sqlite_regex_extract, 3), ops.LPad: _lpad, ops.RPad: _rpad, ops.Repeat: _repeat, ops.Reverse: unary(sa.func._ibis_sqlite_reverse), 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),