Skip to content

Commit

Permalink
refactor(api)!: change as_interval unit argument to be positional…
Browse files Browse the repository at this point in the history
…-only
  • Loading branch information
cpcloud committed Feb 5, 2025
1 parent 926aa90 commit a85d497
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def test_date_truncate(backend, alltypes, df, unit):
def test_integer_to_interval_timestamp(
backend, con, alltypes, df, unit, displacement_type
):
interval = alltypes.int_col.as_interval(unit=unit)
interval = alltypes.int_col.as_interval(unit)
expr = (alltypes.timestamp_col + interval).name("tmp")

def convert_to_offset(offset, displacement_type=displacement_type):
Expand Down Expand Up @@ -629,7 +629,7 @@ def convert_to_offset(offset, displacement_type=displacement_type):
@pytest.mark.notimpl(["datafusion", "druid"], raises=com.OperationNotDefinedError)
@pytest.mark.notimpl(["exasol"], raises=com.OperationNotDefinedError)
def test_integer_to_interval_date(backend, con, alltypes, df, unit):
interval = alltypes.int_col.as_interval(unit=unit)
interval = alltypes.int_col.as_interval(unit)
month = alltypes.date_string_col[:2]
day = alltypes.date_string_col[3:5]
year = alltypes.date_string_col[6:8]
Expand Down
4 changes: 3 additions & 1 deletion ibis/expr/types/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,7 @@ def as_timestamp(self, unit: Literal["s", "ms", "us"], /) -> ir.TimestampValue:
def as_interval(
self,
unit: Literal["Y", "M", "W", "D", "h", "m", "s", "ms", "us", "ns"] = "s",
/,
) -> ir.IntervalValue:
"""Convert an integer to an interval.
Expand Down Expand Up @@ -1518,8 +1519,9 @@ def to_timestamp(
def to_interval(
self,
unit: Literal["Y", "M", "W", "D", "h", "m", "s", "ms", "us", "ns"] = "s",
/,
) -> ir.IntervalValue:
return self.as_interval(unit=unit)
return self.as_interval(unit)

Check warning on line 1524 in ibis/expr/types/numeric.py

View check run for this annotation

Codecov / codecov/patch

ibis/expr/types/numeric.py#L1524

Added line #L1524 was not covered by tests

def convert_base(
self,
Expand Down

0 comments on commit a85d497

Please sign in to comment.