[FEATURE] Define a schema-conflict and mismatched-data handling policy for multi-index queries
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
調査の方向性
まず MergeRuleHelper とその実装である DeepMergeRule、TextKeywordConflictRule、LatestRule を読み、続いて報告された parsing 経路に沿って OpenSearchExprValueFactory と ObjectContent を追跡します。現在、スキーマの競合とドキュメント単位の不一致がどのように処理されているかを比較します。完了の条件は、両方のレイヤーについて合意されたポリシーと定義済みの動作があり、設定可能なモードをどのように指定しテストするかも含まれていることです。
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem?
Querying across multiple indices (e.g. a wildcard index pattern like source=logs-*) has no consistent policy for handling two related but distinct problems:
- Schema-merge-time conflicts: the same field name has genuinely incompatible mapping types across backing indices (e.g.
objectin some, scalartextin others).MergeRuleHelpercurrently resolves conflicts via an ordered rule chain:DeepMergeRuleonly merges struct-vs-struct sub-properties.TextKeywordConflictRuleonly resolves scalar-vs-scalar (text/keyword) conflicts.- Any other mismatch falls through to
LatestRule, which silently picks whichever backing index's mapping was processed last, with no validation, error or coercion.
- Execution-time mismatched data: even once a unified schema is settled on, an individual document's actual value can still fail to match the declared type for that field — not because the document is malformed, but because it came from a differently-mapped index (e.g. dynamic mapping drift across backing indices, or one index legitimately storing the field as a plain string while another stores it as a nested object).
OpenSearchExprValueFactoryblindly casts each document's raw value to the declared type with no defensive handling, so a document from a mismatched-mapping shard throws:
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map
at org.opensearch.sql.opensearch.data.utils.ObjectContent.map(ObjectContent.java:81)
at org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory.parseStruct(OpenSearchExprValueFactory.java:376)
at org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory.parse(OpenSearchExprValueFactory.java:218)
at org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory.construct(OpenSearchExprValueFactory.java:189)
at org.opensearch.sql.opensearch.response.OpenSearchResponse.lambda$handleAggregationResponse$2(OpenSearchResponse.java:263)
at org.opensearch.sql.opensearch.storage.scan.OpenSearchIndexEnumerator.moveNext(OpenSearchIndexEnumerator.java:139)
What solution would you like?
Solutions generally fall into four strategies. Some apply only at execution time (per document, during row deserialization); others apply at both schema-merge time (before query execution, once per index-pattern resolution) and execution time, depending on where they're implemented. Rather than hardcoding a single strategy, these could be exposed as a configurable mode, similar to Spark's CSV/JSON reader mode option (PERMISSIVE, FAILFAST, DROPMALFORMED), letting users choose the behavior that fits their use case:
| Strategy | Applies to | Mechanism | Reference model |
|---|---|---|---|
| Fail-fast | Schema-merge time & execution time | Reject an unresolvable conflict (schema-merge time) or throw on a per-row mismatch (execution time), instead of silently picking one or crashing uncontrolled | Spark (AnalysisException on schema merge; FAILFAST mode for per-record parsing), Trino (fails at split planning), Iceberg (rejects writes with mismatched schema unless mergeSchema is explicitly enabled) |
| Coercion | Schema-merge time & execution time | Pick one common declared type across indices (schema-merge time), or convert a mismatched value into the expected type per row (execution time) | Spark's Parquet mergeSchema read option (widens compatible types across files); Iceberg's mergeSchema write option (adds missing columns at ingestion time, opt-in via write.spark.accept-any-schema) |
| Null on mismatch | Execution time only | When a value doesn't match the expected type, return null for that field/row instead of throwing |
ES|QL's unsupported column type behavior; Spark's PERMISSIVE mode (default) for malformed field values |
| Drop mismatched row | Execution time only | Silently exclude the offending row/document from results entirely | Spark's DROPMALFORMED mode |
What alternatives have you considered?
- Schema-on-read with no unified type: the most permissive, but a much larger architectural change inconsistent with OpenSearch SQL/PPL's current Calcite-based single-row-schema design.
- A
VARIANT-like semi-structured type for conflicting fields: would require a new core data type and query syntax (field:path::type), a larger change than extending the existing merge/parsing layers.
Do you have any additional context?
Related work
This gap has been patched twice before, each time narrowly for one specific type pairing rather than as a general policy:
| Issue / PR | Conflict type | Layer fixed | Fix |
|---|---|---|---|
| #3625 / #3653 | struct vs. struct (differing sub-properties) | Schema-merge time | Added DeepMergeRule to recursively merge sub-properties from both indices |
| #4659 | text vs. keyword (scalar vs. scalar) | Schema-merge time | Added TextKeywordConflictRule, forcing _source-based retrieval instead of doc_values |
Examples
Minimal reproduction (OpenSearch 3.8.0-SNAPSHOT, main HEAD):
PUT /log-repro-object
{
"mappings": {
"properties": {
"log": { "properties": { "ts": { "type": "date" } } }
}
}
}
PUT /log-repro-scalar
{
"mappings": {
"properties": {
"log": { "type": "text" }
}
}
}
POST /log-repro-object/_doc
{ "log": { "ts": "2026-07-06T10:00:00Z" }, "path": "/a" }
POST /log-repro-scalar/_doc
{ "log": "plain string log line", "path": "/b" }
POST /_plugins/_ppl
{ "query": "source = log-repro-* | dedup path" }
- 主要言語
- 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 ·