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

clickhouse-client --queries-file broken for INSERT INTO statements on multiple lines #50471

Open
alexvanolst opened this issue Jun 2, 2023 · 2 comments

Comments

@alexvanolst
Copy link
Contributor

When using clickhouse-client with the --queries-file parameter, valid INSERT INTO queries fail when there are newlines between values to insert

Fiddle link

https://fiddle.clickhouse.com/86e1674a-31b8-43fe-8588-4af5f07bf6aa

Does it reproduce on recent release?

Yes

How to reproduce

  • Which ClickHouse server version to use: Latest (23.4.2.11)
  • Which interface to use, if matters: clickhouse-client with --queries-fine (bug does not appear when using interactive queries)
  • Non-default settings, if any: n/a
  • CREATE TABLE statements for all tables involved:
CREATE TABLE users (uid Int16, name String, age Int16) ENGINE=Memory;
  • Queries to run that lead to unexpected result
INSERT INTO users VALUES (1231, 'John', 33),
  (1232, 'John2', 33);

Expected behavior

Expect INSERT INTO to not fail when newlines are between values

Error message and/or stacktrace

Code: 62. DB::Exception: Syntax error: failed at position 2 ('1232'): 1232, 'John2', 33);
. Expected one of: SELECT query, possibly with UNION, list of union elements, SELECT query, subquery, possibly with UNION, SELECT subquery, SELECT query, WITH, FROM, SELECT, EXPLAIN. (SYNTAX_ERROR)

Additional context

We have some scripts setup to create tables and insert data into clickhouse table using clickhouse-client --queries-file. It is unmanageable to have all values on a single line and the scripts get broken by any SQL formatting tool.

This is also prevents us from automating some things as we have to exclude INSERT INTO statements and execute interactively instead (without --queries-file)

@alexvanolst alexvanolst added the potential bug To be reviewed by developers and confirmed/rejected. label Jun 2, 2023
@tavplubix tavplubix added unexpected behaviour and removed potential bug To be reviewed by developers and confirmed/rejected. labels Jun 2, 2023
@evillique
Copy link
Member

As a workaround, you can do inserts in batches:

INSERT INTO users VALUES (1231, 'John', 1), (1232, 'John2', 2), (1232, 'John3', 3);
INSERT INTO users VALUES (1231, 'John4', 4), (1232, 'John5', 5), (1232, 'John6', 6);

@alexey-milovidov
Copy link
Member

Proposal: #58436

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

No branches or pull requests

4 participants