Skip to content

Converting an infinity float/double literal to Decimal raises a bare decimal.InvalidOperation #4286

Closed

Description

@AP24110011695

Apache Iceberg version

main (0.12.0)

Please describe the bug this is related to

float('inf') is accepted as a valid float/double literal (NaN is rejected at construction, but infinity is a representable Iceberg double value). Converting such a literal to a DecimalType crashes with a bare decimal.InvalidOperation from inside Decimal.quantize, instead of the ValueError("Could not convert X into a Y") that every other impossible conversion in pyiceberg/expressions/literals.py raises:

  • FloatLiteral.to(DecimalType)
  • DoubleLiteral.to(DecimalType)

Describe how to reproduce the bug

from pyiceberg.expressions.literals import DoubleLiteral
from pyiceberg.types import DecimalType

DoubleLiteral(float("inf")).to(DecimalType(10, 2))
# decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

Willingness to contribute

  • Yes. I will be willing to submit a PR for this bug.

Transparent disclosure: this issue was investigated and filed with AI assistance (reproduction verified locally on main @ e3564a5).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions