Reputation: 7214
I have an issue when I am trying to create a temporary table in ClickHouse. I execute simple query and get an error
create TEMPORARY TABLE nn1 as select 1;
message: Code: 113, e.displayText() = DB::Exception: There is no session, e.what() = DB::Exception
Is someone know why it happen and how to solve the issue? I suppos I need start session before doing the query but I don't know how to do this.
I am trying to doing this using ClickHouse's interface for making query. It looks like
Upvotes: 4
Views: 16134
Reputation: 1734
By default all queries done via HTTP interface are stateless.
To use temporary tables you need to have an active session. It's enough to add session_id
parameter with some value to the URL of ClickHouse request.
So for example:
replace http://127.0.0.1:8123/
to http://127.0.0.1:8123/?session_id=mysession
Later requests with the same session_id
will 'remember' temporary tables, settings, etc. you did in previous queries with that session_id
.
Please also remember that sessions use exclusive locks, so you can't run 2 requests with the same session_id concurrently. And by default session lifetime equals 60 seconds, but can be adjusted.
Check the official documentation https://clickhouse.yandex/docs/en/interfaces/http/
Upvotes: 10