Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Fix incorrect parameter resolution (#63710) #64615

Merged
merged 3 commits into from
Nov 5, 2020

Conversation

palesz
Copy link
Contributor

@palesz palesz commented Nov 4, 2020

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 AttributeMaps keeps only one of the Attributes with the same name even if the ids 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 Aliases is not the same in case the Aliases have the same name and same child

It was considered to simpy fix the second issue by just reassigning the same ids to the Aliases 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.

Fix #56013

Andras Palinkas added 2 commits November 4, 2020 23:46
* SQL: Fix incorrect parameter resolution

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.

Fix elastic#56013
@palesz palesz merged commit 3d8e17f into elastic:7.10 Nov 5, 2020
@palesz palesz deleted the fix/56013-7.10 branch January 21, 2021 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant