Commit 20bd641
committed
Bridge live cluster settings into UnifiedQueryContext for PPL_REX_MAX_MATCH_LIMIT
The previous commit defaulted `PPL_REX_MAX_MATCH_LIMIT=10` in the
`UnifiedQueryContext.Builder`'s static defaults map to fix the NPE in
`AstBuilder.visitRexCommand` on the unified path. The default is correct, but
it doesn't respect mid-run cluster overrides — every key in the static map
returns its hardcoded value regardless of `_cluster/settings` updates. This
breaks `CalciteRexCommandIT.testRexMaxMatchConfigurableLimit`, which
explicitly sets the cluster-side limit to 5 and asserts that `max_match=0`
caps at 5; on the unified path it stayed at 10.
This change introduces a `Builder.settings(Settings)` hook that the REST
handler can use to inject the cluster's live `OpenSearchSettings` instance.
Inside `buildSettings()`, the Builder snapshots the live value of
`PPL_REX_MAX_MATCH_LIMIT` into the defaults map, overriding the hardcoded
default when the operator has set a cluster value. Snapshot-at-build matches
the per-HTTP-request lifecycle of `UnifiedQueryContext` and avoids per-call
lookup overhead.
The Builder's existing static defaults map is renamed `settings -> defaults`
to free up the `settings` identifier for the live-cluster-settings concept.
`RestUnifiedQueryAction` gains a `pluginSettings` field (the same
`OpenSearchSettings` instance bound in the Guice module) and forwards it to
the Builder in both `buildContext` and `buildParsingContext`. Both
construction sites — `SQLPlugin.createSqlAnalyticsRouter` and
`TransportPPLQueryAction.<init>` — are updated.
## Why scoped to `PPL_REX_MAX_MATCH_LIMIT` only
The same architectural gap exists for every key in the defaults map
(`QUERY_SIZE_LIMIT`, `PPL_SUBSEARCH_MAXOUT`, `PPL_JOIN_SUBSEARCH_MAXOUT`,
`CALCITE_ENGINE_ENABLED`). For three of those, the static defaults are fine
in practice (no test overrides them mid-run; `head N` covers `QUERY_SIZE_LIMIT`
per-query). `CALCITE_ENGINE_ENABLED` is intentionally pinned to `true` for
the unified path — a cluster override toggling it off would defeat the point
of routing here. So this PR widens only the one key that demonstrably needs
it; widening the snapshot to the rest is a future scope decision tied to
whichever new IT first depends on it.
Signed-off-by: Jialiang Liang <jiallian@amazon.com>1 parent 3763d17 commit 20bd641
4 files changed
Lines changed: 51 additions & 11 deletions
File tree
- api/src/main/java/org/opensearch/sql/api
- plugin/src/main/java/org/opensearch/sql/plugin
- rest
- transport
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
218 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
219 | 238 | | |
220 | 239 | | |
221 | 240 | | |
| |||
232 | 251 | | |
233 | 252 | | |
234 | 253 | | |
| 254 | + | |
235 | 255 | | |
236 | 256 | | |
237 | 257 | | |
| |||
249 | 269 | | |
250 | 270 | | |
251 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
252 | 283 | | |
253 | 284 | | |
254 | 285 | | |
255 | 286 | | |
256 | | - | |
| 287 | + | |
257 | 288 | | |
258 | 289 | | |
259 | 290 | | |
260 | 291 | | |
261 | | - | |
| 292 | + | |
262 | 293 | | |
263 | 294 | | |
264 | 295 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
| 212 | + | |
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | | - | |
158 | | - | |
| 160 | + | |
| 161 | + | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
| 167 | + | |
164 | 168 | | |
165 | 169 | | |
166 | 170 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
88 | | - | |
89 | | - | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | | - | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
0 commit comments