StringLiteral to IntegerType/LongType silently truncates fractional strings, changing predicate meaning
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
バグは pyiceberg/expressions/literals.py にある IntegerType と LongType 向けの StringLiteral.to() 変換にあります。この変換は、DecimalLiteral がすでに使っている既存のヘルパー _to_integral を経由するべきです。まず literal("2.6").to(IntegerType()) を再現し、次に tests/expressions/test_literals.py の test_string_literal を読んでください。小数を含む文字列が両方の整数型で ValueError を発生させ、"2.0" や "1e3" のような整数を表す文字列は引き続き正確に変換されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 1.2k
- フォーク
- 664
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 131
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg-python のほかの issue
-
`inspect.files()` and the other file metadata tables raise `ArrowInvalid` when a snapshot has no manifests対応中かも @YuangGao が 12 日前に担当しました。 オープンkind:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/iceberg-python#4269 ·
メンテナーはふだん 1 日以内に返信
-
`inspect.entries()` raises TypeError when a data file has no column_sizes対応中かも @Rahul-cs50 が 15 日前に担当しました。 オープンkind:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/iceberg-python#4186 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`older_than` reads a naive datetime as UTC and expires snapshots it should keep対応中かも @Rahul-cs50 が 14 日前に担当しました。 オープンkind:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/iceberg-python#4182 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
REST: Send empty first-page pageToken when rest-page-size is set対応中かも @ehddnr301 が 33 日前に担当しました。 オープンkind:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/iceberg-python#4096 ·
メンテナーはふだん 1 日以内に返信
-
PyArrowFileIO: every small S3 write is a 3-request multipart upload; expose allow_delayed_open対応中かも @David-Banquet が 30 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/iceberg-python#4093 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
apache/iceberg-python の issue をすべて見る
似ている issue
-
ライブラリを追加オープンpriority middle
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
KATO-Hiro/AtCoderClans#13015 ·
メンテナーはふだん 1 日以内に返信
-
request-theme
難易度 2/5 1時間未満 初心者へのやさしさ 62/100
LizardByte/ThemerrDB#10024 · コメント 2 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
btclib-org/btclib-node#2505 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
open-webui/open-webui#34462 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
KLayout/klayout#2554 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信