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

[BUG] Invalid aggregation statement should throw SemanticCheckException #2764

Closed
LantaoJin opened this issue Jun 19, 2024 · 1 comment
Closed
Labels
bug Something isn't working untriaged

Comments

@LantaoJin
Copy link
Member

LantaoJin commented Jun 19, 2024

What is the bug?
Invalid aggregation statement could be executed and return meaningless outcome. Further more, if the statement fallback to legacy engine, more confused error will be thrown. A use case reported in #2320

How can one reproduce the bug?

PUT test_index1/_doc/1
{
  "name": "Tom",
  "id" : 1
}
POST /_plugins/_sql
{
  "query": "SELECT id FROM test_index1 GROUP BY name"
}

Return null

What is the expected behavior?
An SemanticCheckException exception is thrown.

For instance,
Spark throws

[MISSING_AGGREGATION] The non-aggregating expression "id" is based on columns which are not participating in the GROUP BY clause.
Add the columns or the expression to the GROUP BY, aggregate the expression, or use "any_value(id)" if you do not care which of the values within a group is returned.;

PostgreSQL throws

Error in query: ERROR: column "test_index1.id" must appear in the GROUP BY clause or be used in an aggregate function

What is your host/environment?

  • Version 2.15
  • Plugins SQL

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

@LantaoJin LantaoJin added bug Something isn't working untriaged labels Jun 19, 2024
@LantaoJin LantaoJin changed the title [BUG] Invalid aggregation statement should throw SyntaxAnalysisException [BUG] Invalid aggregation statement should throw SemanticCheckException Jun 19, 2024
@LantaoJin
Copy link
Member Author

This could be a part of #2767. Close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

1 participant