Skip to content

Commit f58c9d5

Browse files
committed
refactor(api)!: change as_timestamp unit argument to be positional-only
1 parent c5800c2 commit f58c9d5

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

ibis/backends/bigquery/tests/unit/test_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_hashbytes(case, how, dtype, snapshot):
111111
),
112112
)
113113
def test_integer_to_timestamp(case, unit, snapshot):
114-
expr = ibis.literal(case, type=dt.int64).as_timestamp(unit=unit).name("tmp")
114+
expr = ibis.literal(case, type=dt.int64).as_timestamp(unit).name("tmp")
115115
snapshot.assert_match(to_sql(expr), "out.sql")
116116

117117

ibis/backends/druid/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def functional_alltypes(self) -> ir.Table:
115115
# tool that calls itself a time series database or "good for
116116
# working with time series", that lacks a first-class timestamp
117117
# type.
118-
timestamp_col=t.timestamp_col.as_timestamp(unit="ms"),
118+
timestamp_col=t.timestamp_col.as_timestamp("ms"),
119119
)
120120

121121
@property

ibis/backends/flink/tests/test_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_count_star(simple_table, assert_sql):
2222
],
2323
)
2424
def test_timestamp_from_unix(simple_table, unit, assert_sql):
25-
expr = simple_table.d.as_timestamp(unit=unit)
25+
expr = simple_table.d.as_timestamp(unit)
2626
assert_sql(expr)
2727

2828

ibis/expr/types/numeric.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,10 +1420,7 @@ def approx_quantile(
14201420

14211421
@public
14221422
class IntegerValue(NumericValue):
1423-
def as_timestamp(
1424-
self,
1425-
unit: Literal["s", "ms", "us"],
1426-
) -> ir.TimestampValue:
1423+
def as_timestamp(self, unit: Literal["s", "ms", "us"], /) -> ir.TimestampValue:
14271424
"""Convert an integral UNIX timestamp to a timestamp expression.
14281425
14291426
Parameters
@@ -1440,11 +1437,7 @@ def as_timestamp(
14401437
--------
14411438
>>> import ibis
14421439
>>> ibis.options.interactive = True
1443-
>>> t = ibis.memtable(
1444-
... {
1445-
... "int_col": [0, 1730501716, 2147483647],
1446-
... }
1447-
... )
1440+
>>> t = ibis.memtable({"int_col": [0, 1730501716, 2147483647]})
14481441
>>> t.int_col.as_timestamp("s")
14491442
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
14501443
┃ TimestampFromUNIX(int_col, SECOND) ┃
@@ -1513,12 +1506,13 @@ def as_interval(
15131506
"""
15141507
return ops.IntervalFromInteger(self, unit).to_expr()
15151508

1516-
@deprecated(as_of="10.0", removed_in="11.0", instead="use as_timestamp() instead")
1509+
@deprecated(
1510+
as_of="10.0", removed_in="11.0", instead="use as_timestamp(unit) instead"
1511+
)
15171512
def to_timestamp(
1518-
self,
1519-
unit: Literal["s", "ms", "us"] = "s",
1513+
self, unit: Literal["s", "ms", "us"] = "s", /
15201514
) -> ir.TimestampValue:
1521-
return self.as_timestamp(unit=unit)
1515+
return self.as_timestamp(unit)
15221516

15231517
@deprecated(as_of="10.0", removed_in="11.0", instead="use as_interval() instead")
15241518
def to_interval(

0 commit comments

Comments
 (0)