StringLiteral to IntegerType/LongType silently truncates fractional strings, changing predicate meaning
Maintainers usually reply within 1 day
@Shahzeb-DataEngineer is already working on this.
Since Nov 15, 2026.
- #4383 by @Shahzeb-DataEngineer — open
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
The bug is in the StringLiteral.to() conversion for IntegerType and LongType in pyiceberg/expressions/literals.py, which should route through the existing _to_integral helper that DecimalLiteral already uses. Start by reproducing literal("2.6").to(IntegerType()) and then read test_string_literal in tests/expressions/test_literals.py. Done means fractional strings raise ValueError for both integer types while integral strings like "2.0" and "1e3" still convert exactly.
Written by the indexing model from the issue text.
Description
Apache Iceberg version
0.12.0 (latest release)
Please describe the bug 🐞
literal("2.6").to(IntegerType()) returns LongLiteral(2) instead of raising, while DecimalLiteral(Decimal("2.6")).to(IntegerType()) raises ValueError. A bound predicate such as x < "2.6" on an int column therefore becomes x < 2 and wrongly drops rows with x = 2 (verified with expression_evaluator); the same bound literal feeds partition pruning, so files can be skipped too.
The sibling DecimalLiteral.to(IntegerType/LongType) already rejects fractional values via the existing _to_integral helper, with a test spelling out why: rounding would change the predicate (e.g. x > 2.6 becoming x > 3 drops x = 3). The StringLiteral path was missed. The reference Java implementation has no INTEGER/LONG case in StringLiteral.to() and refuses the conversion.
Suggested fix: use the existing _to_integral helper in both StringLiteral.to(IntegerType) and StringLiteral.to(LongType), and update test_string_literal to expect ValueError for fractional strings.
Reproduction (pyiceberg 0.12.0, main @ fce8185):
literal("2.6").to(IntegerType())returnsLongLiteral(2); same for LongTypeliteral("-2.5").to(IntegerType())returnsLongLiteral(-2);literal("0.1").to(LongType())returnsLongLiteral(0)LessThan("x", "2.6")bound to an int column becomesx < 2, andexpression_evaluatorreturns False for a row with x = 2, although x < 2.6 is True- Integral strings still convert exactly:
literal("2.0").to(IntegerType())returns 2,literal("1e3").to(IntegerType())returns 1000
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 664
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 131
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iceberg-python
-
`inspect.files()` and the other file metadata tables raise `ArrowInvalid` when a snapshot has no manifestsPossibly taken @YuangGao claimed this 12 days ago. Openkind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/iceberg-python#4269 ·
Maintainers usually reply within 1 day
-
`inspect.entries()` raises TypeError when a data file has no column_sizesPossibly taken @Rahul-cs50 claimed this 16 days ago. Openkind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/iceberg-python#4186 · 2 comments ·
Maintainers usually reply within 1 day
-
`older_than` reads a naive datetime as UTC and expires snapshots it should keepPossibly taken @Rahul-cs50 claimed this 14 days ago. Openkind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/iceberg-python#4182 · 1 comment ·
Maintainers usually reply within 1 day
-
REST: Send empty first-page pageToken when rest-page-size is setPossibly taken @ehddnr301 claimed this 33 days ago. Openkind:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/iceberg-python#4096 ·
Maintainers usually reply within 1 day
-
PyArrowFileIO: every small S3 write is a 3-request multipart upload; expose allow_delayed_openPossibly taken @David-Banquet claimed this 30 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
apache/iceberg-python#4093 · 3 comments ·
Maintainers usually reply within 1 day
All issues in apache/iceberg-python
Similar issues
-
ライブラリを追加Openpriority middle
Difficulty 1/5 Under an hour Newbie friendliness 62/100
KATO-Hiro/AtCoderClans#13015 ·
Maintainers usually reply within 1 day
-
request-theme
Difficulty 2/5 Under an hour Newbie friendliness 62/100
LizardByte/ThemerrDB#10024 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
btclib-org/btclib-node#2505 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-webui/open-webui#34462 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
KLayout/klayout#2554 · 1 comment ·
Maintainers usually reply within 1 day