clickhouse-docs
clickhouse-docs copied to clipboard
TTL docs don't mention that database name must be specified when using the `ON CLUSTER` clause
Describe the issue
In the article titled Manipulations with Table TTL, there is no mention of the fact that the database name is not optional (if the default database is not being used) when the ON CLUSTER clause is used.
Additional context An example of the problem described above
35432b02b254 :) select currentDatabase()
SELECT currentDatabase()
Query id: 343c7a10-d54b-4511-8ca5-c23387a9afe0
┌─currentDatabase()─┐
│ click │
└───────────────────┘
1 row in set. Elapsed: 0.002 sec.
35432b02b254 :) create user if not exists foo on cluster mycluster
CREATE USER IF NOT EXISTS foo ON CLUSTER mycluster
Query id: 1553e588-3ddb-4f2e-a871-ce0d19f27391
┌─host─────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ clickhouse-2 │ 9000 │ 0 │ │ 3 │ 0 │
│ clickhouse-3 │ 9000 │ 0 │ │ 2 │ 0 │
│ clickhouse-1 │ 9000 │ 0 │ │ 1 │ 0 │
│ clickhouse-4 │ 9000 │ 0 │ │ 0 │ 0 │
└──────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.061 sec.
35432b02b254 :) grant select on * on cluster mycluster to foo
GRANT ON CLUSTER mycluster SELECT ON * TO foo
Query id: 7283d1e8-4f6f-495d-8910-f7c32883154f
┌─host─────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ clickhouse-4 │ 9000 │ 0 │ │ 3 │ 0 │
│ clickhouse-2 │ 9000 │ 0 │ │ 2 │ 0 │
│ clickhouse-3 │ 9000 │ 0 │ │ 1 │ 0 │
│ clickhouse-1 │ 9000 │ 0 │ │ 0 │ 0 │
└──────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.057 sec.
35432b02b254 :) show grants for foo
SHOW GRANTS FOR foo
Query id: e57e71a4-7fc2-48cd-b9bf-3ed9cbf716aa
┌─GRANTS FOR foo───────────────────┐
│ GRANT SELECT ON default.* TO foo │
└──────────────────────────────────┘
1 row in set. Elapsed: 0.001 sec.
Since I'm currently connected to the database click, I would expect that the grants are applied to all tables in the click database, instead of the default database
Here is the result of the same statements when I don't use the ON CLUSTER clause
35432b02b254 :) select currentDatabase()
SELECT currentDatabase()
Query id: d86be97b-5db5-40c5-955b-011372a2a9ea
┌─currentDatabase()─┐
│ click │
└───────────────────┘
1 row in set. Elapsed: 0.001 sec.
35432b02b254 :) create user if not exists foo
CREATE USER IF NOT EXISTS foo
Query id: 4384cb16-fb35-4ebc-aa71-743cab983817
Ok.
0 rows in set. Elapsed: 0.002 sec.
35432b02b254 :) grant select on * to foo
GRANT SELECT ON * TO foo
Query id: 6efeed0f-14ef-4471-a32b-881ff174a2e0
Ok.
0 rows in set. Elapsed: 0.002 sec.
35432b02b254 :) show grants for foo
SHOW GRANTS FOR foo
Query id: 52f620e9-0f76-4d66-ae4f-e99c622d2058
┌─GRANTS FOR foo─────────────────┐
│ GRANT SELECT ON click.* TO foo │
└────────────────────────────────┘
1 row in set. Elapsed: 0.002 sec.