Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pyiceberg/expressions/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def __init__(self) -> None:

@singledispatchmethod
def to(self, type_var: IcebergType) -> Literal: # type: ignore
raise TypeError("Cannot change the type of IntAboveMax")
raise TypeError("Cannot change the type of LongAboveMax")

@to.register(LongType)
def _(self, _: LongType) -> Literal[int]:
Expand All @@ -264,7 +264,7 @@ def __init__(self) -> None:

@singledispatchmethod
def to(self, type_var: IcebergType) -> Literal: # type: ignore
raise TypeError("Cannot change the type of IntBelowMin")
raise TypeError("Cannot change the type of LongBelowMin")

@to.register(LongType)
def _(self, _: LongType) -> Literal[int]:
Expand Down
14 changes: 14 additions & 0 deletions tests/expressions/test_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,20 @@ def test_below_min_int() -> None:
assert b.to(IntegerType()) == IntBelowMin()


def test_above_max_long() -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_above_max_long() -> None:
def test_long_above_max_to_error() -> None:

a = LongAboveMax()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can inline a. Same for LongBelowMin test.

with pytest.raises(TypeError) as e:
a.to(IntegerType())
assert "Cannot change the type of LongAboveMax" in str(e.value)


def test_below_min_long() -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_below_min_long() -> None:
def test_long_below_min_to_error() -> None:

b = LongBelowMin()
with pytest.raises(TypeError) as e:
b.to(IntegerType())
assert "Cannot change the type of LongBelowMin" in str(e.value)


def test_invalid_boolean_conversions() -> None:
assert_invalid_conversions(
literal(True),
Expand Down