Skip to content

Commit 95521c9

Browse files
committed
Default plugins.ppl.rex.max_match.limit=10 on the unified query path
The PPL `rex` command's AstBuilder reads `Settings.Key.PPL_REX_MAX_MATCH_LIMIT` unconditionally and unboxes the result to `int`: int maxMatchLimit = (settings != null) ? settings.getSettingValue(...) : 10; The `(settings != null)` guard only protects against the Settings instance being null — not against `getSettingValue` returning null for a key that the caller never registered. On the unified query path, `UnifiedQueryContext` builds its `Settings` map with only a small whitelist of keys (e.g. `QUERY_SIZE_LIMIT`, `CALCITE_ENGINE_ENABLED` per #5413). For any unregistered key, `getSettingValue` returns null, and the auto-unbox NPEs the planner before any operator-level capability check runs. Every `rex` query through `/_analytics/ppl` (the analytics-engine route's REST front-end) hits this NPE today. Default `PPL_REX_MAX_MATCH_LIMIT=10` in `buildSettings()` so unified-path behavior matches the cluster-side default registered by `OpenSearchSettings.PPL_REX_MAX_MATCH_LIMIT_SETTING` — making the v2 path and the analytics-engine path agree on the same fallback value when neither has an explicit cluster override. Mirrors the precedent Kai introduced for `CALCITE_ENGINE_ENABLED` in #5413. Companion to the OpenSearch core PR onboarding PPL `rex mode=sed` to the analytics-engine route via DataFusion (Part 1 — sed-mode bridge only; extract-mode Rust UDFs deferred to Part 2). Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent 5d31506 commit 95521c9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

api/src/main/java/org/opensearch/sql/api/UnifiedQueryContext.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import static org.opensearch.sql.common.setting.Settings.Key.CALCITE_ENGINE_ENABLED;
99
import static org.opensearch.sql.common.setting.Settings.Key.PPL_JOIN_SUBSEARCH_MAXOUT;
10+
import static org.opensearch.sql.common.setting.Settings.Key.PPL_REX_MAX_MATCH_LIMIT;
1011
import static org.opensearch.sql.common.setting.Settings.Key.PPL_SUBSEARCH_MAXOUT;
1112
import static org.opensearch.sql.common.setting.Settings.Key.QUERY_SIZE_LIMIT;
1213

@@ -123,14 +124,22 @@ public static class Builder {
123124
* org.opensearch.sql.api.parser.PPLQueryParser} reuses the v2 {@code AstBuilder}, which gates
124125
* Calcite-only commands (e.g. {@code visitTableCommand}) on this setting; without the default,
125126
* those commands fail at parse time even when the cluster setting is true.
127+
*
128+
* <p>{@link Settings.Key#PPL_REX_MAX_MATCH_LIMIT} defaults to {@code 10} here because
129+
* {@code AstBuilder.visitRexCommand} reads it unconditionally and unboxes to {@code int} —
130+
* a {@code null} return from {@code getSettingValue} NPEs the planner before any operator-
131+
* level capability check runs. The value mirrors the cluster-side default of {@code 10}
132+
* registered by {@code OpenSearchSettings.PPL_REX_MAX_MATCH_LIMIT_SETTING}, so unified-path
133+
* behavior matches v2-path behavior when neither has an explicit cluster override.
126134
*/
127135
private final Map<Settings.Key, Object> settings =
128136
new HashMap<Settings.Key, Object>(
129137
Map.of(
130138
QUERY_SIZE_LIMIT, SysLimit.DEFAULT.querySizeLimit(),
131139
PPL_SUBSEARCH_MAXOUT, SysLimit.DEFAULT.subsearchLimit(),
132140
PPL_JOIN_SUBSEARCH_MAXOUT, SysLimit.DEFAULT.joinSubsearchLimit(),
133-
CALCITE_ENGINE_ENABLED, true));
141+
CALCITE_ENGINE_ENABLED, true,
142+
PPL_REX_MAX_MATCH_LIMIT, 10));
134143

135144
/**
136145
* Sets the query language frontend to be used.

0 commit comments

Comments
 (0)