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

Syntax error when column named ALL or DISTINCT in distributed query #32391

Closed
DimasKovas opened this issue Dec 8, 2021 · 1 comment · Fixed by #32490
Closed

Syntax error when column named ALL or DISTINCT in distributed query #32391

DimasKovas opened this issue Dec 8, 2021 · 1 comment · Fixed by #32490
Labels
bug Confirmed user-visible misbehaviour in official release comp-distributed Distributed tables

Comments

@DimasKovas
Copy link
Contributor

Describe what's wrong

If a column named ALL or DISTINCT appears in the first position of the select list in a distributed query, the query fails with Syntax error.

In the rewriten query the column name appears without quotation marks, so remote server interprets DISTINCT as part of SELECT DISTINCT instead of column name. Same thing applies to column named ALL.

Does it reproduce on recent release?

Yes, It reproduces on 21.11.5 official build

How to reproduce

  • Which ClickHouse server version to use
  • Which interface to use, if matters
  • Non-default settings, if any
SET prefer_localhost_replica=0
  • CREATE TABLE statements for all tables involved
CREATE TABLE  t0 ("KEY" Int64, "ALL" Int64, "DISTINCT" Int64) ENGINE = MergeTree() ORDER BY KEY
CREATE TABLE dist_t0 ("KEY" Int64, "ALL" Int64, "DISTINCT" Int64) ENGINE = Distributed(test_shard_localhost, default, t0)
  • Sample data for all these tables, use clickhouse-obfuscator if necessary
  • Queries to run that lead to unexpected result
:) select "DISTINCT" from dist_t0

SELECT DISTINCT
FROM dist_t0

Query id: d9024cf2-777e-4f5e-a7fa-f9d2eb8dc661


0 rows in set. Elapsed: 0.013 sec. 

Received exception from server (version 21.11.5):
Code: 62. DB::Exception: Received from localhost:9000. DB::Exception: Received from localhost:9000. DB::Exception: Syntax error: failed at position 22 ('default'): default.t0. Expected one of: UNION, LIMIT, WHERE, WINDOW, DoubleColon, LIKE, GLOBAL NOT IN, end of query, HAVING, AS, DIV, IS, UUID, GROUP BY, INTO OUTFILE, OR, EXCEPT, QuestionMark, OFFSET, BETWEEN, NOT LIKE, MOD, PREWHERE, AND, Comma, alias, ORDER BY, SETTINGS, IN, ILIKE, INTERSECT, FROM, FORMAT, Dot, NOT ILIKE, WITH, NOT, Arrow, token, NOT IN, GLOBAL IN. (SYNTAX_ERROR)
@DimasKovas DimasKovas added the potential bug To be reviewed by developers and confirmed/rejected. label Dec 8, 2021
@vdimir vdimir added bug Confirmed user-visible misbehaviour in official release comp-distributed Distributed tables and removed potential bug To be reviewed by developers and confirmed/rejected. labels Dec 8, 2021
@vdimir
Copy link
Member

vdimir commented Dec 8, 2021

May be related #32374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release comp-distributed Distributed tables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants