[Enhancement] Honor search.allow_expensive_queries when planning a script pushdown

オープン
#5,837 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@RyanL1997 がすでに取り組んでいます。

2026年10月19日 から。

  • #5896 @RyanL1997 による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java
領域
database

調査の方向性

Trace the engine-wide script pushdown paths and check how the plugin reads search settings during planning; the issue names no source files or tests. Use the provided text-field reproduction with search.allow_expensive_queries=false as the first check, then cover the binary and flat_object cases mentioned in the issue. Done means script pushdowns are not emitted when the setting is false, or the rejection clearly identifies the setting and responsible query part.

索引モデルが issue の本文から書いたものです。

説明

enhancement performance
What is wrong

A filter PPL cannot express as a DSL query is planned as a script query. OpenSearch already lets an operator refuse those with search.allow_expensive_queries (default true), but the plugin never consults it. When it is false the shard rejects the script and the user gets an error that names neither the setting nor the part of the query responsible:

java.sql.SQLException: exception while executing query: Failed to fetch data from the index:
the background task failed or interrupted.
  Inner error: Failed to execute phase [query], all shards failed; shardFailures
  { ... QueryShardException[failed to create query: [script] queries cannot be executed
  when 'search.allow_expensive_queries' is set to false.] }

A filter the index can answer succeeds in the same state, so the gate already discriminates correctly at the DSL level — the plugin just does not handle the rejection. allow_expensive_queries appears nowhere in the plugin.

Reproduce

A stock mapping: a text field with no keyword sub-field, so equality cannot become a term.

PUT /txtonly
{"settings":{"number_of_shards":1},
 "mappings":{"properties":{"id":{"type":"keyword"},"msg":{"type":"text"}}}}

POST /txtonly/_doc/1?refresh=true
{"id":"a","msg":"hello world"}

PUT /_cluster/settings
{"transient":{"search.allow_expensive_queries":false}}
POST /_plugins/_ppl   {"query": "source=txtonly | where msg = 'hello world' | fields id"}
query with the setting true with it false
where msg = 'hello world' the row the error above
a filter the index can answer (where id = 'a') the row the row

Both engines reach it: the script pushdown is not Calcite-specific.

What it should do

Either of these; the first is preferable because the answer stays correct.

  1. Plan around it. When the setting is false, do not emit a script pushdown — leave the predicate to the coordinator, which is what the engine already does for every other predicate it cannot push down. Slower, still correct.
  2. Refuse clearly. Report that the query needs a script, name the setting, and say which part of the query caused it.
Scope

Engine-wide rather than specific to one field type: every script pushdown path is affected — a text field without a keyword sub-field as above, a binary field (#5757), and a field type with no doc values at all, such as the flat_object leaves added in #5830, where it was found.

主要言語
Java
スター
175
フォーク
233
平均マージ
3日 36分
マージ済み PR(30日)
41

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opensearch-project/sql のほかの issue

opensearch-project/sql の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。