Skip to content

Commit

Permalink
next
Browse files Browse the repository at this point in the history
  • Loading branch information
kaijennissen committed Apr 18, 2024
1 parent 5ab6928 commit 16af6e8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ibis/backends/sql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,6 @@ def visit_ExtractMonth(self, op, *, arg):
def visit_ExtractDay(self, op, *, arg):
return self.f.extract(self.v.day, arg)

def visit_ExtractDayOfWeek(self, op, *, arg):
return self.f.extract(self.v.dayofweek, arg)

def visit_ExtractDayOfYear(self, op, *, arg):
return self.f.extract(self.v.dayofyear, arg)

Expand Down Expand Up @@ -789,6 +786,10 @@ def visit_TimeTruncate(self, op, *, arg, unit):
def visit_DayOfWeekIndex(self, op, *, arg):
return (self.f.dayofweek(arg) + 6) % 7

def visit_IsoDayOfWeekIndex(self, op, *, arg):
return self.f.dayofweek(arg)


def visit_DayOfWeekName(self, op, *, arg):
# day of week number is 0-indexed
# Sunday == 0
Expand All @@ -797,6 +798,15 @@ def visit_DayOfWeekName(self, op, *, arg):
this=(self.f.dayofweek(arg) + 6) % 7,
ifs=list(itertools.starmap(self.if_, enumerate(calendar.day_name))),
)

def visit_DayOfWeekName(self, op, *, arg):
# day of week number is 0-indexed
# Sunday == 0
# Saturday == 6
return sge.Case(
this=self.f.dayofweek(arg),
ifs=list(itertools.starmap(self.if_, enumerate(calendar.day_name))),
)

def visit_IntervalFromInteger(self, op, *, arg, unit):
return sge.Interval(
Expand Down

0 comments on commit 16af6e8

Please sign in to comment.