Skip to content

SQL: id on Aliases should be same if the Aliases are semantically equal #64652

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

Open
palesz opened this issue Nov 5, 2020 · 2 comments
Open
Labels
:Analytics/SQL SQL querying >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@palesz
Copy link
Contributor

palesz commented Nov 5, 2020

This problem was discovered during the investigation of the #56013 bug. Namely the following problems were discovered:

(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 (meaning they are semantically equal).

For the full explanation and ways we cannot use to fix the second issue, please see: #63710 (comment)

The first issue was fixed as part of #63710 . This issue is to not forget to fix the second one (id reuse).

Take the example (3) above. The Aliases in the projections:

Today How it should look like
100 AS 100#id_1 100 AS 100#id_1
100 AS 100#id_2 100 AS 100#id_1
@palesz palesz added >non-issue :Analytics/SQL SQL querying Team:QL (Deprecated) Meta label for query languages team labels Nov 5, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (:Query Languages/SQL)

@wchaparro wchaparro removed the Team:QL (Deprecated) Meta label for query languages team label Jan 17, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 17, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

4 participants