#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace DB { static bool isUserDefinedFunctionQuery(const ASTPtr & query) { return query->as() || query->as(); } static bool isAccessControlQuery(const ASTPtr & query) { return query->as() || query->as() || query->as() || query->as() || query->as() || query->as() || query->as(); } ASTPtr removeOnClusterClauseIfNeeded(const ASTPtr & query, ContextPtr context, const WithoutOnClusterASTRewriteParams & params) { auto * query_on_cluster = dynamic_cast(query.get()); if (!query_on_cluster || query_on_cluster->cluster.empty()) return query; if ((isUserDefinedFunctionQuery(query) && context->getSettings().ignore_on_cluster_for_replicated_udf_queries && context->getUserDefinedSQLObjectsStorage().isReplicated()) || (isAccessControlQuery(query) && context->getSettings().ignore_on_cluster_for_replicated_access_entities_queries && context->getAccessControl().containsStorage(ReplicatedAccessStorage::STORAGE_TYPE))) { LOG_DEBUG(getLogger("removeOnClusterClauseIfNeeded"), "ON CLUSTER clause was ignored for query {}", query->getID()); return query_on_cluster->getRewrittenASTWithoutOnCluster(params); } return query; } }