Repository navigation
Conversation
|
We already have a function to remove Besides, this PR checks only the |
@tuanpach auto * query_on_cluster = dynamic_cast<ASTQueryWithOnCluster *>(query_ptr.get());
if (database_name != query_on_cluster->cluster)
return false;
auto database = DatabaseCatalog::instance().tryGetDatabase(database_name);
if (database && database->shouldReplicateQuery(context, query_ptr))
{
/// It's Replicated database and query is replicated on database level,
/// so ON CLUSTER clause is redundant.
query_on_cluster->cluster.clear();
return true;
}However, clusters could works with cluster and database names that are different. So :) select * from system.databases \G
SELECT *
FROM system.databases
Query id: c3283f62-34e0-432c-8c4f-c750df300558
...
Row 5:
──────
name: repl_db
engine: Replicated
data_path: /var/lib/clickhouse/store/
metadata_path: /var/lib/clickhouse/store/b38/b38e5ec5-8223-4c0b-84ba-0d6c42d5d61b/
uuid: b38e5ec5-8223-4c0b-84ba-0d6c42d5d61b
engine_full: Replicated('/clickhouse/repl_db', '{shard}', '{replica}')
comment:
...
6 rows in set. Elapsed: 0.002 sec.
:) CREATE TABLE repl_db.table ON CLUSTER '{cluster}' (a Int) ENGINE=MergeTree ORDER BY a;
CREATE TABLE repl_db.`table` ON CLUSTER `{cluster}`
(
`a` Int
)
ENGINE = MergeTree
ORDER BY a
Query id: fc740a42-c44a-455b-8337-6872069c4bcf
Elapsed: 0.151 sec.
Received exception from server (version 24.8.14):
Code: 80. DB::Exception: Received from localhost:9000. DB::Exception: There was an error on [r***]: Code: 80. DB::Exception: It's not initial query. ON CLUSTER is not allowed for Replicated database. (INCORRECT_QUERY) (version 24.8.14.39 (official build)). (INCORRECT_QUERY)I suggest removing |
|
Hi @k-morozov Sorry, I missed your message during the vacation. You mean we should remove the check So if the query is replicated, we don't need |
|
Hello @tuanpach, I'd like to reopen this PR. Allowing ON CLUSTER queries for replicated database can be useful for a seamless migration of a database to replicated engine, so users can still use their old ON CLUSTER ddl queries without change. Right now Konstantin's changes basically make So I suggest to just remove the check and ignore cluster implicitly, or to make the check weaker by adding ignore setting. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Ignore
ON CLUSTERclause in Replicated database.Documentation entry for user-facing changes