Commit a7d35a0
committed
Remove prefix-override branch in shouldOverrideField; scope struct-parent pruning to bin
PR #4606 introduced a `newName.startsWith(originalName + ".")` branch in
`shouldOverrideField` to make `bin` on a nested field work without an explicit
`fields` projection (issue #4482). That heuristic silently removed any column
that happened to be a prefix of an eval target, which broke two real cases:
* Issue #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 #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 #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 #5185
Signed-off-by: Songkan Tang <songkant@amazon.com>1 parent 2804165 commit a7d35a0
2 files changed
Lines changed: 109 additions & 24 deletions
File tree
- core/src/main/java/org/opensearch/sql/calcite
- integ-test/src/test/java/org/opensearch/sql/calcite/remote
Lines changed: 60 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
973 | 973 | | |
974 | 974 | | |
975 | 975 | | |
| 976 | + | |
976 | 977 | | |
977 | 978 | | |
978 | 979 | | |
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 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
980 | 1017 | | |
981 | 1018 | | |
982 | 1019 | | |
| |||
1295 | 1332 | | |
1296 | 1333 | | |
1297 | 1334 | | |
1298 | | - | |
| 1335 | + | |
1299 | 1336 | | |
1300 | 1337 | | |
1301 | 1338 | | |
| |||
1315 | 1352 | | |
1316 | 1353 | | |
1317 | 1354 | | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | 1355 | | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
1338 | | - | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
1339 | 1376 | | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
| 1377 | + | |
| 1378 | + | |
1343 | 1379 | | |
1344 | 1380 | | |
1345 | 1381 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
| |||
86 | 102 | | |
87 | 103 | | |
88 | 104 | | |
| 105 | + | |
| 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 | + | |
89 | 138 | | |
90 | 139 | | |
91 | 140 | | |
| |||
0 commit comments