def _get_engine_type(self, cluster: ClickhouseCluster, table_name: str) -> str: database_name = cluster.get_database() if cluster.is_single_node(): return f"ReplacingMergeTree({self.__version_column})" elif self._unsharded is True: return f"ReplicatedReplacingMergeTree('/clickhouse/tables/{self._storage_set_value}/all/{database_name}/{table_name}', '{{replica}}', {self.__version_column})" else: return f"ReplicatedReplacingMergeTree('/clickhouse/tables/{self._storage_set_value}/{{shard}}/{database_name}/{table_name}', '{{replica}}', {self.__version_column})"
def get_sql(self, cluster: ClickhouseCluster, table_name: str) -> str: cluster_name = cluster.get_clickhouse_cluster_name() assert not cluster.is_single_node() assert cluster_name is not None database_name = cluster.get_database() optional_sharding_key = (f", {self.__sharding_key}" if self.__sharding_key else "") return f"Distributed({cluster_name}, {database_name}, {self.__local_table_name}{optional_sharding_key})"
def _get_zookeeper_path(self, cluster: ClickhouseCluster, table_name: str) -> str: database_name = cluster.get_database() if self._unsharded is True: path = f"/clickhouse/tables/{self._storage_set_value}/all/{database_name}/{table_name}" else: path = f"/clickhouse/tables/{self._storage_set_value}/{{shard}}/{database_name}/{table_name}" path_with_override = settings.CLICKHOUSE_ZOOKEEPER_OVERRIDE.get( path, path) return f"'{path_with_override}'"