Commit 4cf2714
committed
Analyzer: add ambiguity check for unqualified names and align tests
- Added `checkAmbiguousUnqualifiedName(UnresolvedAttribute, List<Attribute>)` in Analyzer to explicitly detect
duplicate unqualified attribute names (e.g., [a].[id], [b].[id]) and throw VerificationException when ambiguous.
Called this method inside `resolveAgainstList(UnresolvedAttribute, Collection<Attribute>)` for all unqualified refs.
- Added new test class `AnalyzerAmbiguityTests`:
• testAmbiguousUnqualifiedThrowsWhenQualifiersExist — expects VerificationException for duplicate qualified names.
• testQualifiedNameBypassesAmbiguityCheck — ensures qualified names skip ambiguity check.
• testNoQualifiersButDuplicateNamesShouldThrow — ensures duplicates without qualifiers are also treated as ambiguous.
- Updated `VerifierTests` (lookup join ambiguity cases):
• Replaced strict `assertEquals` message matching with relaxed assertion accepting both
"Ambiguous unqualified name [...]" and "Unknown column [...] did you mean [...]" styles.
• Added helper `errorMessageOnly(String query)` to extract raw VerificationException messages without formatting checks,
used only in the three ambiguous lookup join tests to avoid coupling test results to specific error message wording.1 parent 2ec32bd commit 4cf2714
File tree
3 files changed
+103
-62
lines changed- x-pack/plugin/esql/src
- main/java/org/elasticsearch/xpack/esql/analysis
- test/java/org/elasticsearch/xpack/esql/analysis
3 files changed
+103
-62
lines changedLines changed: 15 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
1348 | 1352 | | |
1349 | 1353 | | |
1350 | 1354 | | |
1351 | 1355 | | |
1352 | 1356 | | |
1353 | | - | |
1354 | | - | |
1355 | | - | |
1356 | | - | |
1357 | | - | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1358 | 1360 | | |
1359 | 1361 | | |
1360 | 1362 | | |
1361 | 1363 | | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
1368 | 1364 | | |
1369 | | - | |
1370 | | - | |
| 1365 | + | |
1371 | 1366 | | |
1372 | | - | |
| 1367 | + | |
1373 | 1368 | | |
1374 | 1369 | | |
1375 | | - | |
| 1370 | + | |
1376 | 1371 | | |
1377 | | - | |
1378 | 1372 | | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1386 | 1378 | | |
1387 | 1379 | | |
1388 | 1380 | | |
| |||
x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerAmbiguityTests.java
Lines changed: 33 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
52 | 67 | | |
53 | 68 | | |
54 | | - | |
| 69 | + | |
| 70 | + | |
55 | 71 | | |
56 | 72 | | |
57 | 73 | | |
58 | 74 | | |
59 | 75 | | |
60 | 76 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
66 | 82 | | |
67 | 83 | | |
68 | 84 | | |
69 | 85 | | |
70 | 86 | | |
71 | | - | |
72 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
73 | 90 | | |
74 | 91 | | |
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
78 | | - | |
| 95 | + | |
79 | 96 | | |
80 | 97 | | |
81 | 98 | | |
82 | 99 | | |
83 | 100 | | |
84 | 101 | | |
85 | 102 | | |
86 | | - | |
| 103 | + | |
87 | 104 | | |
88 | 105 | | |
89 | 106 | | |
| |||
94 | 111 | | |
95 | 112 | | |
96 | 113 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
100 | 119 | | |
101 | 120 | | |
102 | 121 | | |
Lines changed: 55 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
2237 | 2238 | | |
2238 | 2239 | | |
2239 | 2240 | | |
| 2241 | + | |
2240 | 2242 | | |
2241 | 2243 | | |
2242 | 2244 | | |
2243 | 2245 | | |
2244 | 2246 | | |
2245 | 2247 | | |
2246 | | - | |
2247 | | - | |
2248 | | - | |
2249 | | - | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
2250 | 2252 | | |
2251 | | - | |
2252 | | - | |
2253 | | - | |
2254 | | - | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
2255 | 2260 | | |
2256 | 2261 | | |
| 2262 | + | |
2257 | 2263 | | |
2258 | 2264 | | |
2259 | 2265 | | |
2260 | 2266 | | |
2261 | 2267 | | |
2262 | 2268 | | |
2263 | | - | |
2264 | | - | |
2265 | | - | |
2266 | | - | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
2267 | 2273 | | |
2268 | | - | |
2269 | | - | |
2270 | | - | |
2271 | | - | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
2272 | 2279 | | |
2273 | 2280 | | |
| 2281 | + | |
2274 | 2282 | | |
2275 | 2283 | | |
2276 | 2284 | | |
2277 | 2285 | | |
2278 | 2286 | | |
2279 | 2287 | | |
2280 | | - | |
2281 | | - | |
2282 | | - | |
2283 | | - | |
2284 | | - | |
2285 | | - | |
2286 | | - | |
2287 | | - | |
2288 | | - | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
2289 | 2318 | | |
2290 | 2319 | | |
| 2320 | + | |
2291 | 2321 | | |
2292 | 2322 | | |
2293 | 2323 | | |
| |||
0 commit comments