Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing operations for SQL Server - ExtractEpochSeconds, ExtractDayOfYear, ExtractWeekOfYear #870

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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