Skip to content

add SELECT ALL syntax#18723

Merged
alexey-milovidov merged 11 commits intoClickHouse:masterfrom
ucasfl:select-all
Jan 14, 2021
Merged

add SELECT ALL syntax#18723
alexey-milovidov merged 11 commits intoClickHouse:masterfrom
ucasfl:select-all

Conversation

@ucasfl
Copy link
Copy Markdown
Collaborator

@ucasfl ucasfl commented Jan 4, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Add SELECT ALL syntax. closes #18706

@robot-clickhouse robot-clickhouse added doc-alert pr-feature Pull request with new product feature labels Jan 4, 2021
@alexey-milovidov alexey-milovidov self-assigned this Jan 4, 2021
has_all = true;

if (has_all && select_query->distinct)
throw Exception("Can not use DISTINCT alongside ALL", ErrorCodes::LOGICAL_ERROR);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be syntax error, not logical error.

SELECT DISTINCT ALL 1; -- { clientError 49 }

SELECT sum(number) FROM numbers(10);
SELECT sum(ALL number) FROM numbers(10);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to also test that

sum(ALL DISTINCT number)
sum(DISTINCT ALL number)

yields an error.

fix
@alexey-milovidov
Copy link
Copy Markdown
Member

alexey-milovidov commented Jan 4, 2021

One more detail: we should not throw exceptions from Parser (need to just return false instead).
Because Query Fuzzer is incompatible with it. Example:
https://clickhouse-test-reports.s3.yandex.net/16366/6ec602ad67843a3e2554aed4b1f3fefd10d6ec52/fuzzer/fuzzer.log

@ucasfl
Copy link
Copy Markdown
Collaborator Author

ucasfl commented Jan 5, 2021

One more detail: we should not throw exceptions from Parser (need to just return false instead).
Because Query Fuzzer is incompatible with it. Example:
https://clickhouse-test-reports.s3.yandex.net/16366/6ec602ad67843a3e2554aed4b1f3fefd10d6ec52/fuzzer/fuzzer.log

There are many throw Exception in parser, should we remove all of them?

@alexey-milovidov
Copy link
Copy Markdown
Member

There are many throw Exception in parser, should we remove all of them?

Not necessarily, there are some useful cases... I will fix Fuzzer in another way.

@alexey-milovidov
Copy link
Copy Markdown
Member

Now we have to fix the remaining cases:

f(ALL)
f(ALL, x)

ALL should be treat as identifier.

f(ALL x)

Here ALL should be treat as noop.

@alexey-milovidov
Copy link
Copy Markdown
Member

Maybe also do the same fixes for DISTINCT:

SELECT f(DISTINCT)
SELECT f(DISTINCT, x)

@ucasfl
Copy link
Copy Markdown
Collaborator Author

ucasfl commented Jan 9, 2021

Now we have to fix the remaining cases:

f(ALL)
f(ALL, x)

ALL should be treat as identifier.

f(ALL x)

Here ALL should be treat as noop.

But if the query is SELECT f(ALL) FROM table, what does it mean?

@alexey-milovidov
Copy link
Copy Markdown
Member

It means that the table presumable has a column named ALL.
Example:

SELECT exp(ALL) FROM (SELECT 1 AS ALL)

fix style

fix build
@alexey-milovidov
Copy link
Copy Markdown
Member

#19029

@alexey-milovidov
Copy link
Copy Markdown
Member

I cannot understand why "Docs check" has failed. Just removed the link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL compatibility: support SELECT ALL syntax

3 participants