Skip to content

Commit

Permalink
chore: name to epoch_days
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Aug 23, 2024
1 parent 5be432f commit be065df
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ def execute_timestamp_range(op, **kw):
return pl.datetime_ranges(start, stop, f"{step}{unit}", closed="left")


@translate.register(ops.UnixDate)
@translate.register(ops.EpochDays)
def execute_unix_date(op, **kw):
return translate(op.arg, **kw).dt.epoch("d")

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ def add_query_to_expr(self, *, name: str, table: ir.Table, query: str) -> str:
# generate the SQL string
return parsed.sql(dialect)

def visit_UnixDate(self, op, *, arg):
def visit_EpochDays(self, op, *, arg):
epoch = self.f.date_from_parts(1970, 1, 1)
return self.f.datediff(arg, epoch, self.v.DAY)

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class BigQueryCompiler(SQLGlotCompiler):
ops.Time: "time",
ops.TimeFromHMS: "time_from_parts",
ops.TimestampNow: "current_timestamp",
ops.UnixDate: "unix_date",
ops.EpochDays: "unix_date",
ops.ExtractHost: "net.host",
}

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/datafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DataFusionCompiler(SQLGlotCompiler):
ops.TypeOf,
ops.StringToDate,
ops.StringToTimestamp,
ops.UnixDate,
ops.EpochDays,
)

SIMPLE_OPS = {
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DruidCompiler(SQLGlotCompiler):
ops.TimestampDelta,
ops.Translate,
ops.TypeOf,
ops.UnixDate,
ops.EpochDays,
ops.Unnest,
ops.Variance,
)
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ExasolCompiler(SQLGlotCompiler):
ops.TimestampDiff,
ops.TimestampSub,
ops.TypeOf,
ops.UnixDate,
ops.EpochDays,
ops.Unnest,
)

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def visit_GroupConcat(self, op, *, arg, where, sep, order_by):
def visit_IntervalFromInteger(self, op, *, arg, unit):
return self._value_to_interval(arg, unit)

def visit_UnixDate(self, op, *, arg):
def visit_EpochDays(self, op, *, arg):
return arg - self.f.date_from_parts(1970, 1, 1)

Check warning on line 466 in ibis/backends/sql/compilers/oracle.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/sql/compilers/oracle.py#L466

Added line #L466 was not covered by tests


Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ def test_date_scalar(con, value, func):
)
def test_simple_unix_date_offset(con):
d = ibis.date("2023-04-07")
expr = d.epoch()
expr = d.epoch_days()
result = con.execute(expr)
delta = datetime.date(2023, 4, 7) - datetime.date(1970, 1, 1)
assert result == delta.days
2 changes: 1 addition & 1 deletion ibis/expr/operations/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class TimestampDelta(TemporalDelta):


@public
class UnixDate(Value):
class EpochDays(Value):
"""Return the number of days since the UNIX epoch."""

arg: Value[dt.Date]
Expand Down
4 changes: 2 additions & 2 deletions ibis/expr/types/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def delta(
"""
return ops.DateDelta(left=self, right=other, part=part).to_expr()

def epoch(self) -> ir.IntegerValue:
def epoch_days(self) -> ir.IntegerValue:
"""Return the number of days since the UNIX epoch date.
Examples
Expand Down Expand Up @@ -509,7 +509,7 @@ def epoch(self) -> ir.IntegerValue:
│ 2020-01-01 │ 18262 │
└────────────┴───────┘
"""
return ops.UnixDate(self).to_expr()
return ops.EpochDays(self).to_expr()


@public
Expand Down

0 comments on commit be065df

Please sign in to comment.