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
12 changes: 12 additions & 0 deletions tests/expressions/test_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,18 @@ def test_below_min_int() -> None:
assert b.to(IntegerType()) == IntBelowMin()


def test_long_above_max_to_error() -> None:
with pytest.raises(TypeError) as e:
LongAboveMax().to(IntegerType())
assert "Cannot change the type of LongAboveMax" in str(e.value)


def test_long_below_min_to_error() -> None:
with pytest.raises(TypeError) as e:
LongBelowMin().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