Commit da1410b
authored
[BugFix] Fix eval overwrites MAP root field when assigning multiple dotted-path names (opensearch-project#5185) (opensearch-project#5351)
* [BugFix] Fix eval overwrites MAP root field when assigning multiple dotted-path names (opensearch-project#5185)
Signed-off-by: Songkan Tang <songkant@amazon.com>
* Remove prefix-override branch in shouldOverrideField; scope struct-parent pruning to bin
PR opensearch-project#4606 introduced a `newName.startsWith(originalName + ".")` branch in
`shouldOverrideField` to make `bin` on a nested field work without an explicit
`fields` projection (issue opensearch-project#4482). That heuristic silently removed any column
that happened to be a prefix of an eval target, which broke two real cases:
* Issue opensearch-project#5185 — assigning multiple dotted-path fields from a `spath` MAP root
dropped the root column, so subsequent evals failed with "Field not found".
* Reviewer's case on PR opensearch-project#5351 —
`source=big5 | fields agent | eval agent.name = "test"` dropped the `agent`
column entirely, violating SPL1 semantics where a dotted assignment creates
a literal column without touching any sibling or parent field.
Rather than layer another heuristic (`hasSubFields`) on top of the prefix
branch, this change removes the prefix branch entirely and returns
`shouldOverrideField` to an exact-name match. The command-specific behaviour
that actually needed parent-pruning — `bin` on a nested leaf inside a
struct that OpenSearch exposes as both parent and flattened leaves — is now
handled locally in `visitBin` via `dropStructParentsFor`, which only fires
when the prefixes really exist as struct-parent columns in the current row
schema.
Tests:
* Kept the two spath regression tests from PR opensearch-project#5351
(`CalcitePPLSpathTest`, `CalcitePPLSpathCommandIT`,
`issues/5185.yml`).
* Added `CalciteEvalCommandIT.testEvalDottedNameDoesNotDropStructParent` and
`testEvalDottedNamePreservesStructParent_ImplicitProject` to cover the
reviewer's `agent` case.
* `CalciteBinCommandIT.testBinWithNestedFieldWithoutExplicitProjection` and
`testBinWithEvalCreatedDottedFieldName` still pass via the new
`dropStructParentsFor` path instead of the global prefix branch.
Resolves opensearch-project#5185
Signed-off-by: Songkan Tang <songkant@amazon.com>
* Drop struct parents in projectPlusOverriding when overriding a nested leaf
The previous commit scoped dropStructParentsFor to visitBin only. But
projectPlusOverriding is also called from eval, rex/sed, trendline,
expand, flatten, and patterns. An empirical scratch test showed that
`eval resource.attributes.telemetry.sdk.version = "OVERRIDE"` on the
telemetry index silently lost the override at the implicit `fields *`
projection because tryToRemoveNestedFields deleted the overridden
flat leaf (its parent `resource.attributes.telemetry.sdk` was still
in the row schema).
Move dropStructParentsFor inside projectPlusOverriding, gated on
"the override actually matched an existing column name" (i.e. the
pre-override row schema already had that exact dotted name). This
covers every command that funnels through projectPlusOverriding
without reintroducing the opensearch-project#5185 / reviewer regressions — both of
those paths introduce brand-new dotted names that were not already
in the row schema, so overriddenNames stays empty and the struct
parents (e.g. `agent`, `doc`) survive untouched.
Also add regression coverage in CalciteEvalCommandIT:
- testEvalOverrideOfFlattenedNestedLeafSurvivesImplicitProject
- testEvalOverrideOfFlattenedNestedLeafWithExplicitProject
Signed-off-by: Songkan Tang <songkant@amazon.com>
---------
Signed-off-by: Songkan Tang <songkant@amazon.com>1 parent 8543e63 commit da1410b
5 files changed
Lines changed: 317 additions & 13 deletions
File tree
- core/src/main/java/org/opensearch/sql/calcite
- integ-test/src
- test/java/org/opensearch/sql/calcite/remote
- yamlRestTest/resources/rest-api-spec/test/issues
- ppl/src/test/java/org/opensearch/sql/ppl/calcite
Lines changed: 95 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
951 | 951 | | |
952 | 952 | | |
953 | 953 | | |
| 954 | + | |
954 | 955 | | |
955 | 956 | | |
956 | 957 | | |
957 | 958 | | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
958 | 1008 | | |
959 | 1009 | | |
960 | 1010 | | |
| |||
1270 | 1320 | | |
1271 | 1321 | | |
1272 | 1322 | | |
1273 | | - | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1274 | 1327 | | |
1275 | | - | |
1276 | | - | |
1277 | | - | |
1278 | | - | |
| 1328 | + | |
1279 | 1329 | | |
1280 | 1330 | | |
1281 | 1331 | | |
| |||
1291 | 1341 | | |
1292 | 1342 | | |
1293 | 1343 | | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1294 | 1358 | | |
1295 | 1359 | | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1296 | 1385 | | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
| 1386 | + | |
1305 | 1387 | | |
1306 | 1388 | | |
1307 | 1389 | | |
| |||
Lines changed: 102 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
41 | 59 | | |
42 | 60 | | |
43 | 61 | | |
| |||
86 | 104 | | |
87 | 105 | | |
88 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
89 | 191 | | |
90 | 192 | | |
91 | 193 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
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 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
219 | 242 | | |
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
0 commit comments