A predicate on a multi-valued field matches only when it is pushed down
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 42/100
調査の方向性
Start by reproducing the four queries at the /_plugins/_ppl endpoint and comparing their _explain output, including with pushdown and Calcite fallback disabled. Trace how scalar comparisons receive multi-valued fields in the v2 and Calcite paths, then compare the existing pushdown behavior. Done means predicates such as =, !=, in, and like have consistent multi-value semantics regardless of pipeline position, without silent row loss or type errors.
索引モデルが issue の本文から書いたものです。
説明
What is wrong
An OpenSearch field can hold several values; PPL types it as a scalar. A term query on a multi-valued field has ANY semantics in the index — it matches when any value equals the term — but the in-engine comparison compares the whole list against the literal, so it matches nothing.
Whether a predicate is evaluated in the index or in the engine depends on whether it can be pushed down, which depends on where it sits in the pipeline. So the same predicate over the same data returns different rows depending on what precedes it.
Reproduce
Default settings. Nothing unusual in the mapping.
PUT /arr
{"settings":{"number_of_shards":1},
"mappings":{"properties":{"s":{"type":"keyword"},
"k":{"type":"keyword"},
"n":{"type":"integer"}}}}
POST /arr/_bulk?refresh=true
{"index":{"_id":"1"}}
{"s":"multi","k":["a","b"],"n":[80,443]}
{"index":{"_id":"2"}}
{"s":"single","k":"c","n":22}
POST /_plugins/_ppl {"query": "source=arr | where k = 'a'"}
POST /_plugins/_ppl {"query": "source=arr | head 2 | where k = 'a'"}
| query | rows returned | filter reached the DSL |
|---|---|---|
source=arr | where k = 'a' |
1 | yes |
source=arr | head 2 | where k = 'a' |
0 | no |
source=arr | where n = 80 |
1 | yes |
source=arr | head 2 | where n = 80 |
0 | no |
Document 1 satisfies the predicate in all four. A head in front of the filter changes the answer. The last column is from _explain: FILTER-> is present in the scan's pushdown context for the first and third, absent for the second and fourth.
plugins.calcite.pushdown.enabled=false reaches the same gap without a head.
Both engines
plugins.calcite.enabled=false (v2) gives the same answers, so this is not a Calcite regression — it is long-standing behaviour in both engines.
The mechanism
With plugins.calcite.fallback.allowed=false, the numeric case stops being silent:
POST /_plugins/_ppl {"query":"source=arr | head 2 | where n = 80"}
HTTP 500, code UNKNOWN
java.sql.SQLException: exception while executing query:
class java.util.ArrayList cannot be cast to class java.lang.Integer
The type the engine works with is a scalar while the value it receives is a list:
describe arr -> n: int, k: string
source=arr | eval t=typeof(n) | fields t -> INT
source=arr | fields k, n -> [["a","b"], [80,443]]
Generated code casts the value to the declared scalar type and fails. One array value anywhere in the column is enough: head 2 | where n = 22 fails the same way, even though the document it should match holds a scalar 22.
With fallback allowed the failure is swallowed and the query is answered by the v2 engine instead, which is why the default configuration shows a missing row rather than an error. A keyword column does not throw at all — it just does not match.
Why it matters
- The wrong answer is silent in the default configuration: fewer rows, no warning.
- It applies to every multi-valued field, not to a particular mapping type.
head,sortand any other operator that blocks pushdown moves a predicate from one semantics to the other without the query saying anything about it.
Directions
- Represent a multi-valued field as an
ARRAYin the type system and lower=on one to a quantified comparison (= SOME (...)), which Calcite supports natively. Correct, but it touches the declared type of every field that can hold several values. - Keep the scalar type and give the comparison a multi-value-aware form that the pushdown recognizer and the in-engine path agree on. Narrower, and it can be introduced per operator (
=,!=,in,like).
Either way the fix belongs to the comparison, not to any one field type, and every field benefits.
Context
Found while reviewing #5830, which adds flat_object support. A flat_object leaf holding several values behaves the same way, since it is just another multi-valued column; that PR inherits this rather than introducing it, and says so.
Environment
OpenSearch 3.9.0-SNAPSHOT, opensearch-sql 3.9.0.0-SNAPSHOT. Reproduced on 3.10.0-SNAPSHOT as well.
- 主要言語
- 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 が 107 日前に担当しました。 オープン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
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
PCL-Community/PCL-CE#3907 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 2 日以内に返信
-
area/dependencies area/dependencies/quarkus backport/26.6 backport/26.8 kind/cve severity/critical source/scan-dependencies status/triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
docker-to-squash.py: check_dependencies should find mksquashfs on PATH対応中かも @linzch3 が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
chore
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
lugassawan/swe-workbench#841 ·