Run several queries in a single request

2,835 views
Skip to first unread message

Նարեկ Գալստեան

unread,
Jul 27, 2016, 7:05:48 AM7/27/16
to ClickHouse
Hey, 

I was trying to chain queries like
CREATE DATABASE ...;  INSERT INTO ... ; INSERT INTO b...

But after some debugging realized that everything after the first ; is ignored.
Is this kind of chaining supported in clickhouse currently? 

man...@gmail.com

unread,
Jul 27, 2016, 8:14:36 PM7/27/16
to ClickHouse
That chaining is not supported by default.

It is completely not supported in HTTP interface.
Partial support was added to clickhouse-client (enabled with --multiquery option) only for more easy running of functional tests.

The reason is that we have not worked out, how to write multiple result sets in different formats, and how to parse multiple source streams for INSERTs, that are also possible to be in different formats.

For example, if data for INSERTs is in Values format, streams are easily separated by semicolon. If it is in TabSeparated, JSONEachRow etc, then it becomes tricky: we need to provide "framing" for each format.

(In clickhouse-client with --multiquery option, results are simply concatenated; and data for INSERTs must be provided in single line: this option is intended for functional tests, where it is appropriate, but not for general usage.)

But idea of passing multiple statements at once is very promising, because we could not only save roundtrips, but also apply simultaneous execution of multiple queries in single pass through data, if their pipelines could be partially merged. For example, queries with two distinct GROUP BYs over same data. And we think about that idea.

PS. It's a flaw, that rest of statements are ignored silently, better to throw an exception.

среда, 27 июля 2016 г., 14:05:48 UTC+3 пользователь Նարեկ Գալստեան написал:
Reply all
Reply to author
Forward
0 new messages