OpenSearch/x-pack/plugin/ql
Andras Palinkas 3d8e17f3bd
SQL: Fix incorrect parameter resolution (#63710) (#64615)
Summary of the issue and the root cause:

```
(1) SELECT 100, 100 -> success
(2) SELECT ?, ? (with params: 100, 100) -> success
(3) SELECT 100, 100 FROM test -> Unknown output attribute exception for the second 100
(4) SELECT ?, ? FROM test (params: 100, 100) -> Unknown output attribute exception for the second ?
(5) SELECT field1 as "x", field1 as "x" FROM test -> Unknown output attribute exception for the second "x"
```

There are two separate issues at play here:
1. Construction of `AttributeMap`s keeps only one of the `Attribute`s with the same name even if the `id`s are different (see the `AttributeMapTests` in this PR). This should be fixed no matter what, we should not overwrite attributes with one another during the construction of the `AttributeMap`.
2. The `id` on the `Alias`es is not the same in case the `Alias`es have the same `name` and same `child`

It was considered to simpy fix the second issue by just reassigning the same `id`s to the `Alias`es with the same name and child, but it would not solve the `unknown output attribute exception` (see notes below). This PR covers the fix for the first issue.

Relates to #56013
2020-11-04 20:38:00 -05:00
..
src SQL: Fix incorrect parameter resolution (#63710) (#64615) 2020-11-04 20:38:00 -05:00
test EQL: Refactor testing infrastructure (#62928) 2020-09-28 14:22:56 +03:00
build.gradle Fix Eclipse build (#62733) (#62786) 2020-09-22 17:44:25 -04:00