Skip to content

Commit 3763d17

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 fde168f commit 3763d17

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

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

139148
/**
140149
* Sets the query language frontend to be used.

0 commit comments

Comments
 (0)