Skip to content

Commit

Permalink
fix: Add missing operations for SQL Server - ExtractEpochSeconds, Ext…
Browse files Browse the repository at this point in the history
…ractDayOfYear, ExtractWeekOfYear (#870)

* Add ExtractEpochSeconds operation and other date/time ones

* Removed additional functions
  • Loading branch information
helensilva14 committed May 25, 2023
1 parent 6ebece3 commit 709dd4c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions third_party/ibis/ibis_mssql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,12 @@ def _day_of_week_name(t, expr):
(sa_arg,) = map(t.translate, expr.op().args)
return sa.func.trim(sa.func.format(sa_arg, 'dddd'))


def _string_join(t, expr):
sep, elements = expr.op().args
return sa.func.concat(*map(t.translate, elements))


_operation_registry = alch._operation_registry.copy()

_operation_registry.update(
Expand Down Expand Up @@ -418,11 +420,19 @@ def _string_join(t, expr):
ops.ExtractYear: _extract('year'),
ops.ExtractMonth: _extract('month'),
ops.ExtractDay: _extract('day'),
ops.ExtractDayOfYear: _extract('dayofyear'),
ops.ExtractHour: _extract('hour'),
ops.ExtractMinute: _extract('minute'),
ops.ExtractSecond: _extract('second'),
ops.ExtractMillisecond: _extract('millisecond'),
ops.ExtractWeekOfYear: _extract('iso_week'),
ops.Strftime: _strftime,
ops.ExtractEpochSeconds: fixed_arity(
lambda x: sa.cast(
sa.func.datediff(sa.text('s'), '1970-01-01 00:00:00', x), sa.BIGINT
),
1,
),
# newly added
ops.Lag: _lag,
ops.Lead: _lead,
Expand Down

0 comments on commit 709dd4c

Please sign in to comment.