[BUG] Comparing a string field to both an integer and a decimal literal returns 500 ClassCastException
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
The failure comes from the Calcite RexSimplify$RexSargBuilder.addRange call at RexSimplify.java:3617, reached through RexSimplify$SargCollector.accept2b, so start by reproducing the two-comparison query with the PPL endpoint and reading that path. The open question is whether string-to-number comparison should be allowed at all, which the maintainers need to settle before the literal-type merge can be fixed. Done means the same query either returns consistent results or fails with a 400 instead of a 500.
索引モデルが issue の本文から書いたものです。
説明
What is the bug?
A filter that compares a string field to an integer literal and a decimal literal fails in Calcite's RexSimplify with a ClassCastException.
How can one reproduce the bug?
- Create the index and doc:
curl -s -X PUT localhost:9200/hdemo -H 'Content-Type: application/json' \
-d '{"mappings":{"properties":{"s":{"type":"keyword"},"n":{"type":"integer"},"d":{"type":"double"},"b":{"type":"boolean"},"ts":{"type":"date"}}}}' | jq .acknowledged
curl -s -X POST 'localhost:9200/hdemo/_doc?refresh=true' -H 'Content-Type: application/json' \
-d '{"s":"abc","n":7,"d":1.5,"b":true,"ts":"2026-01-02T03:04:05Z"}' | jq .result
- Either comparison on its own works (
where s = 0andwhere s = 0.5each return no rows). - Both together fail:
curl -s -X POST localhost:9200/_plugins/_ppl -H 'Content-Type: application/json' \
-d '{"query":"source=hdemo | where s = 0.5 or s = 0"}' | jq -c '{status, type: .error.type, error: .error.details[0:120]}'
# {"status":500,"type":"ClassCastException","error":"class java.math.BigDecimal cannot be cast to class java.lang.Double (java.math.BigDecimal and java.lang.Double are in mo"}
- Two separate
wherecommands fail too, because they get merged:where s = 0.5 | where s = 0, orwhere s <= 0.5 | where 0 = s. Reversing the literal order flips the message (Double cannot be cast to BigDecimal).
What is the expected behavior?
No rows, the same as each comparison on its own, or a 400 if comparing a string to a number is meant to be rejected. Not a 500.
What is your host/environment?
- mainline (3.10.0-SNAPSHOT, c7e2cea98), single node. Same result with
plugins.calcite.pushdown.enabled=false.
Do you have any screenshots?
N/A
Do you have any additional context?
- Stack:
RexSimplify$RexSargBuilder.addRange(RexSimplify.java:3617)←RexSimplify$SargCollector.accept2b. The implicit cast ofsto a number gives the two comparisons different literal types (DOUBLE vs DECIMAL), and the Sarg builder merges them into one range set without unifying the types. - Whether string = number comparison should be allowed at all is a separate question. Today it's accepted silently (
where s = 0→ 200). - Found by a property-based type checker (hegel).
- 主要言語
- Java
- スター
- 176
- フォーク
- 237
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 34
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
opensearch-project/sql のほかの issue
-
bug untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
opensearch-project/sql#5990 ·
メンテナーはふだん 1 日以内に返信
-
bug untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
opensearch-project/sql#5983 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"対応中かも @nagendramohan が 106 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
opensearch-project/sql#5684 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
[DOC] Calcite settings documentation missing examples対応中かも @AzazelSensei が 64 日前に担当しました。 オープンdocumentation PPL
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
opensearch-project/sql#4806 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
calcite enhancement Meta performance PPL untriaged
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
opensearch-project/sql#5991 ·
メンテナーはふだん 1 日以内に返信
opensearch-project/sql の issue をすべて見る
似ている issue
-
Document the isv:HDFGroup Linux package repositories and signing key対応中かも @brtnfld が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
checkstyle/checkstyle#23174 ·
メンテナーはふだん 1 日以内に返信
-
bug follow-up lane:backlog
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Sanne/incus-spawn#2620 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Execute API reports every non-400 error, including 404 "not found", with reason "System Error"オープンuntriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
opensearch-project/ml-commons#5296 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信